Read Method (SqlShimDataReader)
|
|---|
'Declaration
Public Overrides Function Read() As Boolean |
|
|---|
public override bool Read() |
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 |