TestComplete samples (both built-in and additional) are located in the <Users>\Public\Public Documents\TestComplete 14 Samples folder.
Some file managers display the Public Documents folder as Documents.
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:
-
This example uses the OrdersDB.mdb file that is part of the additional sample package. To use it, download this package from support.smartbear.com/downloads/testcomplete/samples/ and install it. After the installation is over, you can find the database in the <TestComplete 14 Samples>\Desktop\Checkpoints\XML\DataGridViewSample folder.
-
Using the Microsoft.Jet.OLEDB.4.0 provider requires that you run your script in the 32-bit version of TestComplete.
TestComplete 32-bit executable is located in the <TestComplete>\Bin folder.
JavaScript, JScript
function ADOCommandDemo()
{
// 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 = "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 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)
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 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);
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 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);
}