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.

Copy code
ERROR: Invalid Code Highlighting Language

### Example of a data reader

Copy code

    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-26.3 Function Reference 26.1-26.3 All View Local Help Center View Online Help Center Version: