Description
TestComplete includes special program objects that let you easily access data stored in an Excel sheet, CSV file or in an ADO database table. These objects are called drivers. They are typically needed to perform data-driven tests, however, you can also use them to retrieve data from the mentioned storages.
The DDT
object is used to create drivers for ADO database tables, Excel sheets and files holding comma-separated data (CSV file). Its methods return special “driver” objects that have access to values stored in the mentioned data storages.
Note: | The object is only available if the Data-Driven Testing plugin is installed in TestComplete. See Using DDT Drivers. |
Members
Example
The code below connects to the specified database, retrieves information about the name of the command used by the database's myTable table, posts this name to the test log and then closes the connection to the database.
Note: |
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 ADODriverExample()
{
// 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);
// Closes the connection to the specified database
DDT.ADODriver(ConStr, tName).ADOConnectionObject.Close();
}
Python
def ADODriverExample():
# 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)
# Closes the connection to the specified database
DDT.ADODriver(ConStr, tName).ADOConnectionObject.Close()
VBScript
Sub ADODriverExample
' 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)
' Closes the connection to the specified database
DDT.ADODriver(ConStr, tName).ADOConnectionObject.Close
End Sub
DelphiScript
function ADODriverExample;
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);
// Closes the connection to the specified database
DDT.ADODriver(ConStr, tName).ADOConnectionObject.Close();
end;
C++Script, C#Script
function ADODriverExample()
{
// 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);
// Closes the connection to the specified database
DDT["ADODriver"](ConStr, tName)["ADOConnectionObject"]["Close"]();
}
See Also
Using DDT Drivers
DDTDriver Object
Data-Driven Testing
Using Scripts for Data-Driven Testing