TestComplete samples (both built-in and additional) are located in the <Users>\Public\Public Documents\TestComplete 15 Samples folder.
Some file managers display the Public Documents folder as Documents.
Description
Use this property to obtain the ADO Connection
object, which the ADODriverObj driver uses to work with a recordset holding the desired data.
Declaration
ADODriverObj.ADOConnection
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 Connection
object used by ADODriverObj.
Example
The code below connects to the specified database, performs some actions over the database's records and then closes the connection by using the ADOConnection
property.
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/testcomplete/downloads/samples and install it. After the installation is over, you can find the database in the <TestComplete 15 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 ADOConnectionDemo()
{
// 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";
// Performs some actions over the table records
// Closes the connection to the specified database
DDT.ADODriver(ConStr, tName).ADOConnectionObject.Close();
}
Python
def ADOConnectionDemo():
# 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"
# Performs some actions over the table records
# Closes the connection to the specified database
DDT.ADODriver(ConStr, tName).ADOConnectionObject.Close()
VBScript
Sub ADOConnectionDemo
' 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"
' Performs some actions over the table records
' Closes the connection to the specified database
Call DDT.ADODriver(ConStr, tName).ADOConnectionObject.Close
End Sub
DelphiScript
function ADOConnectionDemo;
var ConStr, tName;
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';
// Performs some actions over the table records
// Closes the connection to the specified database
DDT.ADODriver(ConStr, tName).ADOConnectionObject.Close();
end;
C++Script, C#Script
function ADOConnectionDemo()
{
// 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";
// Performs some actions over the table records
// Closes the connection to the specified database
DDT["ADODriver"]( ConStr, tName )["ADOConnectionObject"]["Close"]();
}