dotConnect for SugarCRM Documentation
Devart.Data Namespace / SqlShimDataReader Class / Read Method
Example

Read Method (SqlShimDataReader)
Advances the SqlShimDataReader to the next record.
Syntax
'Declaration
 
Public Overrides Function Read() As Boolean
 

Return Value

true if there are more rows; otherwise, false.
Remarks
The default position of the SqlShimDataReader is prior to the first record. Therefore, you must call Read to begin accessing any data.

While the SqlShimDataReader is in use, the associated Devart.Data.Sugar.SugarConnection is busy serving it until you call Close.

Example
The following example creates a Devart.Data.Sugar.SugarConnection, a Devart.Data.Sugar.SugarCommand, and a SqlShimDataReader. The example reads through the data, writing it out to the console. Finally, the example closes the SqlShimDataReader, then the Devart.Data.Sugar.SugarConnection.
public void ReadMyData(string myConnString)
{
  string mySelectQuery = "SELECT id, name FROM Campaigns";
  SugarConnection sugarConnection = new SugarConnection(myConnString);
  SugarCommand sugarCommand = new SugarCommand(mySelectQuery,sugarConnection);
  sugarConnection.Open();
  SugarDataReader sugarReader;
  sugarReader = sugarCommand.ExecuteReader();
  // Always call Read before accessing data.
  while (sugarReader.Read()) {
    Console.WriteLine(sugarReader.GetString(0) + ", " + sugarReader.GetString(1));
  }
  // always call Close when done reading.
  sugarReader.Close();
  // Close the connection when done with it.
  sugarConnection.Close();
}
Public Sub ReadMyData(myConnString As String)
  Dim mySelectQuery As String = "SELECT id, name FROM Campaigns"
  Dim sugarConnection As New SugarConnection(myConnString)
  Dim sugarCommand As New SugarCommand(mySelectQuery, sugarConnection)
  sugarConnection.Open()
  Dim sugarReader As SugarDataReader
  sugarReader = sugarCommand.ExecuteReader()
  ' Always call Read before accessing data.
  While sugarReader.Read()
    Console.WriteLine(sugarReader.GetString(0) + ", " _
      + sugarReader.GetString(1))
  End While
  ' always call Close when done reading.
  sugarReader.Close()
  ' Close the connection when done with it.
  sugarConnection.Close()
End Sub
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