Read Method (SqlShimDataReader)
public override bool Read()
'Declaration
Public Overrides Function Read() As Boolean
Return Value
true if there are more rows; otherwise, false.
The following example creates a
Devart.Data.FreshBooks.FreshBooksConnection, a
Devart.Data.FreshBooks.FreshBooksCommand, 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.FreshBooks.FreshBooksConnection.
public void ReadMyData(string myConnString)
{
string mySelectQuery = "SELECT Id, LastName FROM Client";
FreshBooksConnection freshbooksConnection = new FreshBooksConnection(myConnString);
FreshBooksCommand freshbooksCommand = new FreshBooksCommand(mySelectQuery,freshbooksConnection);
freshbooksConnection.Open();
FreshBooksDataReader freshbooksReader;
freshbooksReader = freshbooksCommand.ExecuteReader();
// Always call Read before accessing data.
while (freshbooksReader.Read()) {
Console.WriteLine(freshbooksReader.GetString(0) + ", " + freshbooksReader.GetString(1));
}
// always call Close when done reading.
freshbooksReader.Close();
// Close the connection when done with it.
freshbooksConnection.Close();
}
Public Sub ReadMyData(myConnString As String)
Dim mySelectQuery As String = "SELECT Id, LastName FROM Client"
Dim freshbooksConnection As New FreshBooksConnection(myConnString)
Dim freshbooksCommand As New FreshBooksCommand(mySelectQuery, freshbooksConnection)
freshbooksConnection.Open()
Dim freshbooksReader As FreshBooksDataReader
freshbooksReader = freshbooksCommand.ExecuteReader()
' Always call Read before accessing data.
While freshbooksReader.Read()
Console.WriteLine(freshbooksReader.GetString(0) + ", " _
+ freshbooksReader.GetString(1))
End While
' always call Close when done reading.
freshbooksReader.Close()
' Close the connection when done with it.
freshbooksConnection.Close()
End Sub