dotConnect for Salesforce Documentation
Devart.Data.Salesforce Namespace / SalesforceCommand Class / Parameters Property
Example

In This Topic
    Parameters Property
    In This Topic
    Syntax
    'Declaration
     
    Public Shadows ReadOnly Property Parameters As SalesforceParameterCollection
    public new SalesforceParameterCollection Parameters {get;}

    Property Value

    The parameters of a SQL statement or a stored procedure. The default value is an empty collection.
    Remarks
    By default, you have to construct this collection and provide values for it manually. However, if you choose to use autosynchronization mode by setting ParameterCheck property to true you can have the collecton adjusted automatically. Please refer to article Using Parameters in dotConnect for Salesforce for detailed information on using this mode.
    Example
    The following example creates a SalesforceConnection, SalesforceCommand, fills its parameters and displays them. An UPDATE statement with the parameters involved is executed then.
    static void CreateCommand(SalesforceConnection salesforceConnection, string mySelectQuery, SalesforceParameter[] myParamArray) 
    { 
            SalesforceCommand salesforceCommand = new SalesforceCommand(mySelectQuery, salesforceConnection); 
            string myMessage = ""; 
            for (int i = 0; i < myParamArray.Length; i++) 
            { 
                    salesforceCommand.Parameters.Add(myParamArray[i]); 
                    myMessage += salesforceCommand.Parameters[i].ToString() + "\n"; 
            } 
            Console.Write(myMessage); 
            try 
            { 
                    salesforceConnection.Open(); 
                    salesforceCommand.ExecuteNonQuery(); 
            } 
            finally 
            { 
                    salesforceConnection.Close(); 
            } 
    } 
     
    static void Main(string[] args) 
    { 
            SalesforceParameter[] myParams = new SalesforceParameter[]  
                    { 
                    new SalesforceParameter("OldName", "GenePoint"), 
                    new SalesforceParameter("NewName", "GenePoint Inc.") 
                    }; 
            SalesforceConnection salesforceConnection1 = new SalesforceConnection("Server=login.salesforce.com;
                User Id= [email protected];Password=mypassword;Security Token=qweASDzcx1234567890rtyui;"); 
            CreateCommand(salesforceConnection1,"UPDATE Account SET Name = :NewName WHERE Name = :OldName",myParams); 
    }
    Public Sub CreateCommand(ByVal salesforceConnection As Devart.Data.Salesforce.SalesforceConnection, _
            ByVal mySelectQuery As String, ByVal myParamArray() As Devart.Data.Salesforce.SalesforceParameter)
            Dim salesforceCommand As New Devart.Data.Salesforce.SalesforceCommand(mySelectQuery, salesforceConnection)
            Dim myMessage As String = ""
            Dim i As Integer
            For i = 0 To (myParamArray.Length - 1)
                    salesforceCommand.Parameters.Add(myParamArray(i))
                    myMessage = String.Concat(myMessage, " ", salesforceCommand.Parameters(i).ToString())
            Next
            Console.WriteLine(myMessage)
            Try
                    salesforceConnection.Open()
                    salesforceCommand.ExecuteNonQuery()
            Finally
                    salesforceConnection.Close()
            End Try
    End Sub
    
    Sub Main()
            Dim myP1 As New Devart.Data.Salesforce.SalesforceParameter
            myP1.ParameterName = "OldName"
            myP1.Value = "GenePoint"
            Dim myP2 As New Devart.Data.Salesforce.SalesforceParameter
            myP2.ParameterName = "NewName"
            myP2.Value = "GenePoint Inc."
            Dim myParams(1) As Devart.Data.Salesforce.SalesforceParameter
            myParams(0) = myP1
            myParams(1) = myP2
            Dim salesforceConnection1 As New Devart.Data.Salesforce.SalesforceConnection(
                        "Server=login.salesforce.com;User Id= [email protected];Password=mypassword;" & _
                    "Security Token=qweASDzcx1234567890rtyui;")
            CreateCommand(salesforceConnection1, "UPDATE Account SET Name = :NewName WHERE Name = :OldName", myParams)
    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