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

SalesforceCommand Class
Represents a SQL statement or stored procedure to execute against Salesforce.com or Database.com.
Syntax
Remarks
The SalesforceCommand class provides the following methods for executing commands against the Salesforce.com or Database.com database:
Item Description
ExecuteReader Executes commands that return rows.
Devart.Common.DbCommandBase.ExecutePageReader Returns a specific subset of rows when paging through the results of a query.
ExecuteNonQuery Executes SQL commands such as INSERT, DELETE, UPDATE.
ExecuteScalar Retrieves a single value (for example, an aggregate value) from a data source.

If execution of the command results in a fatal SalesforceException, the SalesforceConnection may close. However, the user can reopen the connection and continue.

Example
The following example uses the ExecuteReader method of SalesforceCommand, along with SalesforceDataReader and SalesforceConnection, to select rows from a table.
public void ReadMyData(string myConnString) 
{ 
        string mySelectQuery = "SELECT ID, Name FROM Account"; 
        SalesforceConnection salesforceConnection = new SalesforceConnection(myConnString); 
        SalesforceCommand salesforceCommand = new SalesforceCommand(mySelectQuery,salesforceConnection); 
        salesforceConnection.Open(); 
        SalesforceDataReader salesforceReader; 
        salesforceReader = salesforceCommand.ExecuteReader(); 
        // Always call Read before accessing data. 
        while (salesforceReader.Read()) { 
                Console.WriteLine(salesforceReader.GetString(0) + ", " + salesforceReader.GetString(1)); 
        } 
        // always call Close when done reading. 
        salesforceReader.Close(); 
        // Close the connection when done with it. 
        salesforceConnection.Close(); 
}
Public Sub ReadMyData(myConnString As String)
        Dim mySelectQuery As String = "SELECT ID, Name FROM Account"
        Dim salesforceConnection As New SalesforceConnection(myConnString)
        Dim salesforceCommand As New SalesforceCommand(mySelectQuery, salesforceConnection)
        salesforceConnection.Open()
        Dim salesforceReader As SalesforceDataReader
        salesforceReader = salesforceCommand.ExecuteReader()
        ' Always call Read before accessing data. 
        While salesforceReader.Read()
                Console.WriteLine(salesforceReader.GetString(0) & ", " & salesforceReader.GetString(1))
        End While
        ' always call Close when done reading. 
        salesforceReader.Close()
        ' Close the connection when done with it. 
        salesforceConnection.Close()
End Sub
Inheritance Hierarchy

System.Object
   System.MarshalByRefObject
      System.ComponentModel.Component
         System.Data.Common.DbCommand
            Devart.Common.DbCommandBase
               Devart.Data.Salesforce.SalesforceCommand

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