ADOCommand Property

Applies to TestComplete 12.60, last modified on September 17, 2018

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 name of the ADO Command object used by the specified table to work with a recordset and posts this name to the test log.

Note:

Using the Microsoft.Jet.OLEDB.4.0 provider requires that you run your script in the 32-bit version of TestComplete.

JavaScript, JScript

function ADOCommandDemo()
{
  // Specifies the connection string
  var ConStr = "Provider=Microsoft.Jet.OLEDB.4.0;" +
  "Data Source=C:\\Microsoft Visual Studio\\VB98\\biblio.mdb";
  // Specifies the name of the table
  var tName = "myTable";
  // Obtains the ADO Command object name
  var cName = DDT.ADODriver(ConStr, tName).ADOCommandObject.Name;
  // Posts this name to the test log
  Log.Message(cName);
}

Python

def ADOCommandDemo():
  # Specifies the connection string
  ConStr = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=C:\\Microsoft Visual Studio\\VB98\\biblio.mdb"
  # Specifies the name of the table
  tName = "myTable"
  # Obtains the ADO Command object name
  cName = DDT.ADODriver(ConStr, tName).ADOCommandObject.Name
  # Posts this name to the test log
  Log.Message(cName)

VBScript

Sub ADOCommandDemo
  ' Specifies the connection string
  ConStr = "Provider=Microsoft.Jet.OLEDB.4.0;" + _
  "Data Source=C:\Microsoft Visual Studio\VB98\biblio.mdb"
  ' Specifies the name of the table
  tName = "myTable"
  ' Obtains the ADO Command object name
  cName = DDT.ADODriver(ConStr, tName).ADOCommandObject.Name
  ' Posts this name to the test log
  Log.Message(cName)
End Sub

DelphiScript

function ADOCommandDemo;
var ConStr, tName, cName;
begin
  // Specifies the connection string
  ConStr := 'Provider=Microsoft.Jet.OLEDB.4.0;' +
  'Data Source=C:\Microsoft Visual Studio\VB98\biblio.mdb';
  // Specifies the name of the table
  tName := 'myTable';
  // Obtains the ADO Command object name
  cName := DDT.ADODriver(ConStr, tName).ADOCommandObject.Name;
  // Posts this name to the test log
  Log.Message(cName);
end;

C++Script, C#Script

function ADOCommandDemo()
{
  // Specifies the connection string
  var ConStr = "Provider=Microsoft.Jet.OLEDB.4.0;" +
  "Data Source=C:\\Microsoft Visual Studio\\VB98\\biblio.mdb";
  // Specifies the name of the table
  var tName = "myTable";
  // Obtains the ADO Command object name
  var cName = DDT["ADODriver"]( ConStr, tName )["ADOCommandObject"]["Name"];
  // Posts this name to the test log
  Log["Message"](cName);
}

See Also

ADOConnection Property

Highlight search results