ADO.CreateADOTable

Applies to TestComplete 15.70, last modified on December 17, 2024

The following code illustrates how you can use the IAQAADOTable object, based on the TADOTable class. The TestProc routine accesses data in the table and posts them to the test log.

Notes:

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, i;
  // 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"]();
}

Highlight search results