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

In This Topic
    SalesforceDataReader Class
    In This Topic
    Reads a forward-only stream of rows from Salesforce.com or Database.com.
    Syntax
    Remarks
    To create a SalesforceDataReader, you must call the ExecuteReader method of the SalesforceCommand object, rather than directly using a constructor.

    System.Data.Common.DbDataReader.IsClosed and RecordsAffected are the only properties that you can call after the SalesforceDataReader is closed. In some cases, you must call Close() before you can call RecordsAffected.

    Example
    The following example creates a SalesforceConnection, a SalesforceCommand, and a SalesforceDataReader. The example reads through the data, writing it out to the console. Finally, the example closes the SalesforceDataReader, then the SalesforceConnection.
    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.Data.Common.DbDataReader
             Devart.Common.DbDataReaderBase
                Devart.Data.Salesforce.SalesforceDataReader

    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