ADO.CreateADOTable Method

Applies to TestComplete 14.70, last modified on April 22, 2021

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 or ConnectionString property).
  • Specify the table name (set the TableName property).
  • Open the table using the Open method or the Active 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:

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 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( ! 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 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 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 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 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 14 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

Highlight search results