Share this page

# DoDataRead

.NET Vuser Functions

Reads records from a DataReader object.

    void LrReplayUtils.DoDataRead( DbDataReader reader, DataTable valueTable, bool readToEnd, int numRecordsToRead );

## VB.NET

    Sub LrReplayUtils.DoDataRead( ByVal reader As DbDataReader, ByRef valueTable As DataTable, ByVal readToEnd As Boolean, ByVal numRecordsToRead As Integer)

reader | The DataReader object to read records from. Input.
valueTable | A DataTable, to be filled with the values read from the DataReader. Output.
readToEnd | True to read all records available in the DataReader. False to read the number of records specified in numRecordsToRead. Input
numRecordsToRead | When readToEnd is false, read this number of records from the DataReader. Input.

DoDataRead reads records from a DataReader object and outputs a DataTable containing the data.

Note: Do not add this function manually to a script. It is generated by VuGen automatically.

## Parameterization

Parameterization is not applicable to this function.

## Example

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.Close

Example 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();
          }
        }
      }
    }

Tips to improve your search results... VuGen Function Reference Version 26.1 Function Reference 26.1 All View Local Help Center View Online Help Center Version: