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
Creates a new IAQAADOTable
object and returns a reference to it.
Declaration
ADO.CreateADOTable()
Result | An IAQAADOTable object |
Applies To
The method is applied to the following object:
Result Value
An object of the IAQAADOTable
type.
Remarks
The IAQAADOTable
object is an analogue of a Borland VCL TADOTable
object. Methods and properties are identical.
For detailed information on the underlying TADOTable
object, see VCL documentation on ADODB classes.
Once the IAQAADOTable
object is created, you can use it to navigate through the table and to add, delete or modify records in it. To do this, you must first:
- Establish a connection to the database (set the
Connection
orConnectionString
property). - Specify the table name (set the
TableName
property). - Open the table using the
Open
method or theActive
property.
Example
The following code illustrates how you can use the IAQAADOTable
object in your scripts. The TestProc
routine access data in the table and posts them 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/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 TestProc()
{
var Tbl;
// Create an IAQAADOTable object
Tbl = ADO.CreateADOTable();
// Specify the connection string
Tbl.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;"+
"Data Source=C:\\Users\\Public\\Documents\\TestComplete 15 Samples\\Desktop\\Checkpoints\\XML\\DataGridViewSample\\OrdersDB.mdb";
// Specify the table name
Tbl.TableName = "orders";
// Open the table
Tbl.Open();
// Process records and post data to the test log
Log.AppendFolder("Customers from Canada");
Tbl.First();
while( ! Tbl.EOF)
{
if (Tbl.FieldByName("state").Value == "Canada")
Log.Message(Tbl.FieldByName("name").Value);
Tbl.Next();
}
Tbl.Close();
}
Python
def TestProc():
# Create an IAQAADOTable object
Tbl = ADO.CreateADOTable()
# Specify the connection string
Tbl.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" +\
"Data Source=C:\\Users\\Public\\Documents\\TestComplete 14 Samples\\Desktop\\Checkpoints\\XML\\DataGridViewSample\\OrdersDB.mdb"
# Specify the table name
Tbl.TableName = "orders"
# Open the table
Tbl.Open()
# Process records and post data to the test log
Log.AppendFolder("Customers from Canada")
Tbl.First()
while not Tbl.EOF:
if (Tbl.FieldByName("state").Value == "Canada"):
Log.Message(Tbl.FieldByName("name").Value)
Tbl.Next()
Tbl.Close()
VBScript
Sub TestProc
' Create an IAQAADOTable object
Set Tbl = ADO.CreateADOTable
' Specify the connection string
Tbl.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;"+_
"Data Source=C:\Users\Public\Documents\TestComplete 15 Samples\Desktop\Checkpoints\XML\DataGridViewSample\OrdersDB.mdb"
' Specify the table name
Tbl.TableName = "orders"
' Open the table
Tbl.Open
' Process records and post data to the test log
Log.AppendFolder("Customers from Canada")
Tbl.First
While Not Tbl.EOF
If aqString.Format("%s", Tbl.FieldByName("state").Value) = "Canada" Then
Log.Message Tbl.FieldByName("name").Value
End If
Tbl.Next
WEnd
Tbl.Close
End Sub
DelphiScript
procedure TestProc;
var
Tbl : OleVariant;
begin
// Create an IAQAADOTable object
Tbl := ADO.CreateADOTable;
// Specify the connection string
Tbl.ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;'+
'Data Source=C:\Users\Public\Documents\TestComplete 15 Samples\Desktop\Checkpoints\XML\DataGridViewSample\OrdersDB.mdb';
// Specify the table name
Tbl.TableName := 'orders';
// Open the table
Tbl.Open;
// Process records and post data to the test log
Log.AppendFolder('Customers from Canada');
Tbl.First;
while not Tbl.EOF do
begin
if (aqString.Format('%s',Tbl.FieldByName('state').Value) = 'Canada') then
Log.Message(Tbl.FieldByName('name').Value);
Tbl.Next;
end;
Tbl.Close;
end;
C++Script, C#Script
function TestProc()
{
var Tbl;
// Create an IAQAADOTable object
Tbl = ADO["CreateADOTable"]();
// Specify the connection string
Tbl["ConnectionString"] = "Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=C:\\Users\\Public\\Documents\\TestComplete 15 Samples\\Desktop\\Checkpoints\\XML\\DataGridViewSample\\OrdersDB.mdb";
// Specify the table name
Tbl["TableName"] = "orders";
// Open the table
Tbl["Open"]();
// Process the first ten records and post data to the test log
Log["AppendFolder"]("Customers from Canada");
Tbl["First"]();
while(! Tbl["EOF"])
{
if (Tbl["FieldByName"]("state")["Value"] == "Canada")
Log["Message"](Tbl["FieldByName"]("name")["Value"]);
Tbl["Next"]();
};
// Close the table
Tbl["Close"]();
}
See Also
ADO.CreateADOQuery
ADO.CreateADODataset
ADO.CreateADOStoredProc