Reads a forward-only stream of rows from Adobe Commerce.
The following example creates a
MagentoConnection, a
MagentoCommand, and a
MagentoDataReader. The example reads through the data, writing it out to the console. Finally, the example closes the
MagentoDataReader, then the
MagentoConnection.
public void ReadMyData(string myConnString) {
MagentoConnection adobe commerceConnection = new MagentoConnection(myConnString);
MagentoCommand adobe commerceCommand = (MagentoCommand)adobe commerceConnection.CreateCommand();
adobe commerceCommand.CommandText = "SELECT customer_id, firstname, lastname FROM Customers";
adobe commerceConnection.Open();
MagentoDataReader adobe commerceReader = adobe commerceCommand.ExecuteReader();
try {
// Always call Read before accessing data.
while (adobe commerceReader.Read()) {
Console.WriteLine(adobe commerceReader.GetInt32(0).ToString() + " " +
adobe commerceReader.GetString(1) + " " + adobe commerceReader.GetString(2));
}
}
finally {
// always call Close when done reading.
adobe commerceReader.Close();
// Close the connection when done with it.
adobe commerceConnection.Close();
}
}
Public Sub ReadMyData(ByVal myConnString As String)
Dim adobe commerceConnection As New MagentoConnection(myConnString)
Dim adobe commerceCommand As MagentoCommand = adobe commerceConnection.CreateCommand()
adobe commerceCommand.CommandText = "SELECT customer_id, firstname, lastname FROM Customers"
adobe commerceConnection.Open()
Dim adobe commerceReader As MagentoDataReader = adobe commerceCommand.ExecuteReader()
Try
' Always call Read before accessing data.
While adobe commerceReader.Read()
Console.WriteLine(String.Concat(adobe commerceReader.GetInt32(0).ToString(), " ", _
adobe commerceReader.GetString(1), " ", adobe commerceReader.GetString(2)))
End While
Finally
' always call Close when done reading.
adobe commerceReader.Close()
' Close the connection when done with it.
adobe commerceConnection.Close()
End Try
End Sub
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