Applies to TestComplete 14.40, last modified on May 21, 2020

Description

Use the ADODriver method to create a driver object for a recordset that can be accessed via Microsoft’s ADO DB (the recordset can be a table or result of an SQL query). You can then use this driver to iterate through the recordset, obtain values stored in its fields and use them in your data-driven tests. The names and order of the driver columns coincide with the order and names of the recordset columns.

Declaration

DDT.ADODriver(ConnectionStringTableName)

ConnectionString [in]    Required    String    
TableName [in]    Required    String    
Result An ADODriver object

Applies To

The method is applied to the following object:

Parameters

The method has the following parameters:

ConnectionString

Specifies the connection string used to connect to the database holding the desired recordset.

TableName

Specifies the name of the desired table or a SELECT SQL statement that will be executed to obtain the recordset.

Result Value

An ADODriver object that provides access to data stored in a recordset.

Remarks

The DDT object is available only if the Data-Driven Testing plugin is installed.

For information on working with DDT drivers, see Using DDT Drivers.

For information on specifics and limitations of the ADO DDT driver, see Using Database Tables as Data Storages.

Example

The ADODriverExample procedure connects to the specified database, retrieves information about the text of the command used by the database's table, posts this command text to the test log, and then closes the connection to the database.

Notes:

JavaScript, JScript

function ADODriverExample()
{
 // Specifies the connection string
  var ConStr = "Provider=Microsoft.Jet.OLEDB.4.0;" +
  "Data Source=C:\\Users\\Public\\Documents\\TestComplete 14 Samples\\Desktop\\Checkpoints\\XML\\DataGridViewSample\\OrdersDB.mdb";
  // Specifies the name of the table
  var tName = "orders";
  // Obtains the ADO Command text
  var cText = DDT.ADODriver(ConStr, tName).ADOCommandObject.CommandText;
  // Posts this command text to the test log
  Log.Message(cText);
  // Closes the connection to the specified database
  DDT.ADODriver(ConStr, cText).ADOConnectionObject.Close();
}

Python

def ADODriverExample():
  # Specifies the connection string
  ConStr = "Provider=Microsoft.Jet.OLEDB.4.0;" + \
  "Data Source=C:\\Users\\Public\\Documents\\TestComplete 14 Samples\\Desktop\\Checkpoints\\XML\\DataGridViewSample\\OrdersDB.mdb"
  # Specifies the name of the table
  tName = "orders"
  # Obtains the ADO Command text
  cText = DDT.ADODriver(ConStr, tName).ADOCommandObject.CommandText
  # Posts this command text to the test log
  Log.Message(cText)
  # Closes the connection to the specified database
  DDT.ADODriver(ConStr, cText).ADOConnectionObject.Close()

VBScript

Sub ADODriverExample
   ' Specifies the connection string
  ConStr = "Provider=Microsoft.Jet.OLEDB.4.0;" + _
  "Data Source=C:\Users\Public\Documents\TestComplete 14 Samples\Desktop\Checkpoints\XML\DataGridViewSample\OrdersDB.mdb"
  ' Specifies the name of the table
  tName = "orders"
  ' Obtains the ADO Command text
  cText = DDT.ADODriver(ConStr, tName).ADOCommandObject.CommandText
  ' Posts this command text to the test log
  Log.Message(cText)
  ' Closes the connection to the specified database
  DDT.ADODriver(ConStr, tText).ADOConnectionObject.Close
End Sub

DelphiScript

function ADODriverExample;
var ConStr, tName, cText;
begin
  // Specifies the connection string
  ConStr := 'Provider=Microsoft.Jet.OLEDB.4.0;' +
  'Data Source=C:\Users\Public\Documents\TestComplete 14 Samples\Desktop\Checkpoints\XML\DataGridViewSample\OrdersDB.mdb';
  // Specifies the name of the table
  tName := 'orders';
  // Obtains the ADO Command text
  cText := DDT.ADODriver(ConStr, tName).ADOCommandObject.CommandText;
  // Posts this command text to the test log
  Log.Message(cText);
  // Closes the connection to the specified database
  DDT.ADODriver(ConStr, cText).ADOConnectionObject.Close();
end;

C++Script, C#Script

function ADODriverExample()
{
  // Specifies the connection string
  var ConStr = "Provider=Microsoft.Jet.OLEDB.4.0;" +
  "Data Source=C:\\Users\\Public\\Documents\\TestComplete 14 Samples\\Desktop\\Checkpoints\\XML\\DataGridViewSample\\OrdersDB.mdb";
  // Specifies the name of the table
  var tName = "orders";
  // Obtains the ADO Command text
  var cText = DDT["ADODriver"]( ConStr, tName )["ADOCommandObject"]["CommandText"];
  // Posts this command text to the test log
  Log["Message"](cText);
  // Closes the connection to the specified database
  DDT["ADODriver"](ConStr, cText)["ADOConnectionObject"]["Close"]();
}

See Also

DDTDriver Object
Using DDT Drivers
Using Database Table as Data Storages
Data-Driven Testing

Highlight search results