Example: DoDataRead
This example executes a data read from an SQL connection.
Dim connectionString_1 As [String]
connectionString_1 = "Data Source=myDbServer;User ID=myuser;Password=mypwd;Connect Timeout=26"
SqlConnection_1 = New SqlConnection(connectionString_1)
SqlConnection_1.Open
SqlCommand_1 = New SqlCommand("SELECT * FROM Northwind.dbo.Orders", SqlConnection_1)
SqlDataReader_1 = SqlCommand_1.ExecuteReader
LrReplayUtils.DoDataRead(SqlDataReader_1, valueTable_2, false, 11)
DATASET_XML(2)
SqlConnection_1.CloseExample of a data reader
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient; using System.Configuration; using System.Text;
namespace DataReader {
class Program {
static void Main(string[] args) {
using ( SqlConnection connection = new SqlConnection(
ConfigurationManager.AppSettings["ConnectionString"])) {
connection.Open();
SqlCommand command = new SqlCommand(ConfigurationManager.AppSettings["Query"], connection);
SqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{
object o;
Console.WriteLine("---");
object o1 = reader.GetValue(4);
Console.WriteLine(o1);
}
// Call Close when done reading.
reader.Close();
}
}
}
}

