ExecuteReader(CommandBehavior) Method
The following example creates a
ZohoBooksCommand, then executes it by passing a string that is SQL SELECT statement, and a string to use to connect to the data source. The
System.Data.CommandBehavior is then set to CloseConnection.
|
|---|
public void CreateZohoBooksDataReader(string mySelectQuery,string zohoBooksConnectionString)
{
ZohoBooksConnection zohoBooksConnection = new ZohoBooksConnection(zohoBooksConnectionString);
ZohoBooksCommand zohoBooksCommand = new ZohoBooksCommand(mySelectQuery, zohoBooksConnection);
zohoBooksCommand.Connection.Open();
ZohoBooksDataReader zohoBooksReader = zohoBooksCommand.ExecuteReader(CommandBehavior.CloseConnection);
while(zohoBooksReader.Read())
{
Console.WriteLine(zohoBooksReader.GetString(0));
}
zohoBooksReader.Close();
} |
|
|---|
Public Sub CreateZohoBooksDataReader(mySelectQuery As String, _
zohoBooksConnectionString As String)
Dim zohoBooksConnection As New ZohoBooksConnection(zohoBooksConnectionString)
Dim zohoBooksCommand As New ZohoBooksCommand(mySelectQuery, zohoBooksConnection)
zohoBooksCommand.Connection.Open()
Dim zohoBooksReader As ZohoBooksDataReader = zohoBooksCommand.ExecuteReader(CommandBehavior.CloseConnection)
While zohoBooksReader.Read()
Console.WriteLine(zohoBooksReader.GetString(0))
End While
zohoBooksReader.Close()
End Sub |