Description
Use the DBTable.ConnectionString
property to obtain or specify the connection settings, which TestComplete will use to connect to the database, whose data should be compared with the DBTable project element that corresponds to the DBTable object.
You can use the property to specify a database that contains the data you want to compare and the database engine. The name of the database table must be the same as the name of the table, which you use to create the DBTable project element. For example, if the DBTable element was created for the Orders table, then the database specified by the ConnectionString property must contain the Orders table. Else, an error will occur.
|
Declaration
DBTableObj.ConnectionString
Read-Write Property | String |
DBTableObj | An expression, variable or parameter that specifies a reference to a DBTable object |
Applies To
The property is applied to the following object:
Property Value
String that specifies the connection settings.
Example
The code below specifies a connection string - the login and password that will be used to connect to a database. After that, the routine connects to this database and compares its content with stored data.
Notes:
-
This sample uses Jet OLE DB Provider 4.0 to connect to the database. If you use another version of Microsoft Jet, just replace the version number in the code.
-
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 ConStringExample()
{
// Specifies a DB Table element
var DBTab = DBTables.Table1;
// Specifies a connection string
DBTab.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=C:\\Work\\MyDB.mdb;";
// Specifies the login and password
DBTab.Login = "Tester";
DBtab.Password = "123";
// Connects to the database using
// the specified connection parameters
// and compares its content with stored data
DBTab.Check;
}
Python
def ConStringExample():
# Specifies a DB Table element
DBTab = DBTables.Table1
# Specifies a connection string
DBTab.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=C:\\Work\\MyDB.mdb;"
# Specifies the login and password
DBTab.Login = "Tester"
DBTab.Password = "123"
# Connects to the database using
# the specified connection parameters
# and compares its content with stored data
DBTab.Check()
VBScript
Sub ConStringExample
' Specifies a DB Table element
Set DBTab = DBTables.Table1
' Specifies a connection string
DBTab.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + _
"Data Source=C:\Work\MyDB.mdb;"
' Specifies the login and password
DBTab.Login = "Tester"
DBtab.Password = "123"
' Connects to the database using
' the specified connection parameters
' and compares its content with stored data
DBTab.Check
End Sub
DelphiScript
function ConStringExample();
var DBTab;
begin
// Specifies a DB Table element
DBTab := DBTables.Table1;
// Specifies a connection string
DBTab.ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;' +
'Data Source=C:\Work\MyDB.mdb;';
// Specifies the login and password
DBTab.Login := 'Tester';
DBtab.Password := '123';
// Connects to the database using
// the specified connection parameters
// and compares its content with stored data
DBTab.Check;
end;
C++Script, C#Script
function ConStringExample()
{
// Specifies a DB Table element
var DBTab = DBTables["Table1"];
// Specifies a connection string
DBTab["ConnectionString"] = "Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=C:\\Work\\MyDB.mdb;";
// Specifies the login and password
DBTab["Login"] = "Tester";
DBtab["Password"] = "123";
// Connects to the database using
// the specified connection parameters
// and compares its content with stored data
DBTab["Check"];
}