Represents a SQL statement or stored procedure to execute against Salesforce.com or Database.com.
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
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