dotConnect for Salesforce Documentation
Devart.Data.Salesforce Namespace / SalesforceCommand Class / CreateParameter Method
Example

In This Topic
    CreateParameter Method (SalesforceCommand)
    In This Topic
    Creates a new instance of a SalesforceParameter object.
    Creates a new instance of a SalesforceParameter object.
    Syntax
    'Declaration
     
    Public Shadows Function CreateParameter() As SalesforceParameter
    public new SalesforceParameter CreateParameter()

    Return Value

    Remarks
    This method is a strongly-typed version of System.Data.IDbCommand.CreateParameter. See SalesforceParameter to find out more ways to create a parameter.
    Example
    This sample shows how to create a parameter using CreateParameter function.
    public void CreateParam(SalesforceConnection salesforceConnection) 
    { 
            SalesforceCommand salesforceCommand = new SalesforceCommand("SELECT * FROM Account WHERE Name=:Name",salesforceConnection); 
            SalesforceParameter myParam = salesforceCommand.CreateParameter(); 
            myParam.SalesforceDbType = Devart.Data.Salesforce.SalesforceType.String; 
            myParam.Value = "GenePoint"; 
            myParam.ParameterName = "Name"; 
            salesforceCommand.Parameters.Add(myParam); 
            salesforceConnection.Open(); 
            SalesforceDataReader salesforceReader = null;  
            try 
            { 
                    salesforceReader = salesforceCommand.ExecuteReader();  
                    while (salesforceReader.Read()) 
                    { 
                            Console.WriteLine(salesforceReader.GetString(0) + ", " + salesforceReader.GetString(1) + ", " + salesforceReader.GetString(2)); 
                    } 
            } 
            finally 
            { 
                    salesforceReader.Close(); 
                    salesforceConnection.Close(); 
            } 
    }
    Public Sub CreateParam(salesforceConnection As SalesforceConnection)
            Dim salesforceCommand As New SalesforceCommand("SELECT * FROM Account WHERE Name=:Name", salesforceConnection)
            Dim myParam As SalesforceParameter = salesforceCommand.CreateParameter()
            myParam.SalesforceDbType = Devart.Data.Salesforce.SalesforceType.[String]
            myParam.Value = "GenePoint"
            myParam.ParameterName = "Name"
            salesforceCommand.Parameters.Add(myParam)
            salesforceConnection.Open()
            Dim salesforceReader As SalesforceDataReader = Nothing
            Try
                    salesforceReader = salesforceCommand.ExecuteReader()
                    While salesforceReader.Read()
                            Console.WriteLine(salesforceReader.GetString(0) & ", " & salesforceReader.GetString(1) & ", " & salesforceReader.GetString(2))
                    End While
            Finally
                    salesforceReader.Close()
                    salesforceConnection.Close()
            End Try
    End Sub
    Requirements

    Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

    See Also