ADO.NET Provider for Act! CRM

Build 23.0.8839

Querying with the DataReader

The CData ADO.NET Provider for Act! CRM implements two ADO.NET interfaces you can use to retrieve data from Act! CRM: ActCRMDataAdapter and ActCRMDataReader objects. Whereas ActCRMDataAdapter objects retrieve a single result set of all the data that matches a query, ActCRMDataReader objects fetch data in subset increments as needed.

Using the ActCRMDataReader

The ActCRMDataReader retrieves data faster than the ActCRMDataAdapter because it can retrieve data in pages. As you read data from the ActCRMDataReader, it periodically requests the next page of results from the data source, if required. This causes results to be returned at a faster rate. The following example selects all the columns from the Activities table:

C#

string connectionString = "URL=https://myActCRMserver.com;User=myUser;Password=myPassword;ActDatabase=MyDB;";

using (ActCRMConnection connection = new ActCRMConnection(connectionString)) {
  ActCRMCommand cmd = new ActCRMCommand("SELECT * FROM Activities", connection);
  
  ActCRMDataReader rdr = cmd.ExecuteReader();

  while (rdr.Read()) {
    Console.WriteLine(String.Format("\t{0} --> \t\t{1}", rdr["FullName"], rdr["Company"]));
  }
}

VB.NET

Dim connectionString As String = "URL=https://myActCRMserver.com;User=myUser;Password=myPassword;ActDatabase=MyDB;"

Using connection As New ActCRMConnection(connectionString)
  Dim cmd As New ActCRMCommand("SELECT * FROM Activities", connection)

  Dim rdr As ActCRMDataReader = cmd.ExecuteReader()

  While rdr.Read()
    Console.WriteLine([String].Format(vbTab & "{0} --> " & vbTab & vbTab & "{1}", rdr("FullName"), rdr("Company")))
  End While
End Using

Copyright (c) 2024 CData Software, Inc. - All rights reserved.
Build 23.0.8839