ADOCommand Property

Applies to TestComplete 15.70, last modified on December 17, 2024

Description

Use this property to obtain the ADO Command object, which the ADODriverObj driver uses to work with a recordset containing the desired data.

Declaration

ADODriverObj.ADOCommand

Read-Only Property An ADO Command object
ADODriverObj An expression, variable or parameter that specifies a reference to an ADODriver object

Applies To

The property is applied to the following object:

Property Value

The ADO Command object used by ADODriverObj.

Remarks

You can use the returned ADO Command object to execute only SQL queries (SELECT, UPDATE, INSERT, etc.), it does not allow executing SQLCMD scripts.

Example

The code below obtains the information about the text of the command used by the database’s table to work with a recordset and posts this command text to the test log.

Notes:

JavaScript, JScript

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

Python

def ADOCommandDemo():
  # 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)

VBScript

Sub ADOCommandDemo
  ' Specifies the connection string
  ConStr = "Provider=Microsoft.Jet.OLEDB.4.0;" + _
  "Data Source=C:\Users\Public\Documents\TestComplete 15 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)
End Sub

DelphiScript

function ADOCommandDemo;
var ConStr, tName, cText;
begin
  // Specifies the connection string
  ConStr := 'Provider=Microsoft.Jet.OLEDB.4.0;' +
  'Data Source=C:\Users\Public\Documents\TestComplete 15 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);
end;

C++Script, C#Script

function ADOCommandDemo()
{
  // Specifies the connection string
  var ConStr = "Provider=Microsoft.Jet.OLEDB.4.0;" +
  "Data Source=C:\\Users\\Public\\Documents\\TestComplete 15 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);
}

See Also

ADOConnection Property

Highlight search results