dotConnect for Salesforce Documentation
Devart.Data.Salesforce Namespace / SalesforceConnection Class / CreateCommand Method
Example

In This Topic
    CreateCommand Method (SalesforceConnection)
    In This Topic
    Creates and returns a SalesforceCommand object associated with the SalesforceConnection.
    Creates and returns a SalesforceCommand object associated with the SalesforceConnection.
    Syntax
    'Declaration
     
    Public Shadows Function CreateCommand() As SalesforceCommand
    public new SalesforceCommand CreateCommand()

    Return Value

    Remarks
    You can use this method as an alternative to common SalesforceCommand constructors.
    Example
    In this sample SalesforceCommand object is created. It is automatically associated with SalesforceConnection that created it.
    public void CreateSalesforceCommand(string myConnString) 
    { 
            SalesforceConnection salesforceConnection = new SalesforceConnection(myConnString); 
            SalesforceCommand salesforceCommand = salesforceConnection.CreateCommand(); 
            salesforceCommand.CommandText = "INSERT INTO Account(Name) Values('New account')"; 
            salesforceConnection.Open(); 
            try 
            { 
                    salesforceCommand.ExecuteNonQuery(); 
            } 
            finally 
            { 
                    salesforceConnection.Close(); 
            } 
    }
    Public Sub CreateSalesforceCommand(myConnString As String)
            Dim salesforceConnection As New SalesforceConnection(myConnString)
            Dim salesforceCommand As SalesforceCommand = salesforceConnection.CreateCommand()
            salesforceCommand.CommandText = "INSERT INTO Account(Name) Values('New account')"
            salesforceConnection.Open()
            Try
                    salesforceCommand.ExecuteNonQuery()
            Finally
                    salesforceConnection.Close()
            End Try
    End Sub
    See Also