BDE.CreateTable Method

Applies to TestComplete 14.0, last modified on January 23, 2019

Description

Creates a new object of the IAQATable type (an analogue of the VCL TTable type).

Note: This method requires the Borland Database Engine to be installed on your computer.

Declaration

BDE.CreateTable()

Result An IAQATable object

Applies To

The method is applied to the following object:

Result Value

An object of the IAQATable type.

Remarks

The IAQATable object provides the same functionality for scripts as a TTable object does in VCL applications. It implements the same methods and properties, under the same names. See the VCL documentation for TTable.

Once the IAQATable object is created, you can link it with a table and then navigate through it and to add, delete or modify records in it. To do this, you must first:

  • Specify the database, which the table belongs to (the DatabaseName property).
  • Specify the table type (the TableType property).
  • Specify the file of the table located on hard disk (the TableName property).
  • Finally call the Open method to start working with the table.

Example

The following code executes a database query from the script. The query returns the names of vendors in California. Its results are copied one by one to the test log.

JavaScript, JScript

function TestProc()
{
  var w;
  // Create a new table
  w = BDE.CreateTable();
  // Specify the database
  w.DatabaseName = "DBDEMOS";
  // Specify the table name
  w.TableName = "vendors.db";
  // Specify the table type
  w.TableType = ttParadox;
  // Open the table
  w.Open();
  // Move to the first record
  w.First();
  // Iterate through all records and
  // post the value of the VendorName field to the test log
  while (! w.EOF)
  {
    // Insert a message into the test log
    Log.Message(w.FieldByName("VendorName").AsString);
    // Move to the next record
    w.Next();
  }
}

Python

def TestProc():
  # Create a new table
  w = BDE.CreateTable()
  # Specify the database
  w.DatabaseName = "DBDEMOS"
  # Specify the table name
  w.TableName = "vendors.db"
  # Specify the table type
  w.TableType = ttParadox
  # Open the table
  w.Open()
  # Move to the first record
  w.First()
  # Iterate through all records and
  # post the value of the VendorName field to the test log
  while not w.EOF:
    # Insert a message into the test log
    Log.Message(w.FieldByName("VendorName").AsString)
    # Move to the next record
    w.Next()

VBScript

Sub TestProc
  ' Create a new table
  Set w = BDE.CreateTable
  ' Specify the database
  w.DatabaseName = "DBDEMOS"
  ' Specify the table name
  w.TableName = "vendors.db"
  ' Specify the table type
  w.TableType = ttParadox
  ' Open the table
  w.Open
  ' Move to the first record
  w.First
  ' Iterate through all records and
  ' post the value of the VendorName field to the test log
  While Not w.EOF
    ' Insert a message into the test log
    Log.Message w.FieldByName("VendorName").AsString
    ' Move to the next record
    w.Next
  Wend
End Sub

DelphiScript

procedure TestProc;
var
  w: OleVariant;
begin
  // Create a new table
  w := BDE.CreateTable;
  with w do
  begin
    // Specify the database
    DatabaseName := 'DBDEMOS';
    // Specify the table name
    TableName := 'vendors.db';
    // Specify the table type
    TableType := ttParadox;
  end;
  // Open the table
  w.Open;
  // Move to the first record  w.First;
  // Iterate through all records and
  // post the value of the VendorName field to the test log
  while not aqConvert.VarToBool(w.EOF) do
  begin
    // Insert a message into the test log
    Log.Message(w.FieldByName('VendorName').AsString);
    // Move to the next record
    w.Next;
  end;
end;

C++Script, C#Script

function TestProc()
{
  var w;
  // Create a new table
  w = BDE["CreateTable"]();
  // Specify the database
  w["DatabaseName"] = "DBDEMOS";
  // Specify the table name
  w["TableName"] = "vendors.db";
  // Specify the table type
  w["TableType"] = 1; // ttParadox
  // Open the table
  w["Open"]();
  // Move to the first record
  w["First"]();
  // Iterate through all records and
  // post the value of the VendorName field to the test log
  while (!w["EOF"])
  {
    // Insert a message into the test log
    Log["Message"](w["FieldByName"]("VendorName")["AsString"]);
    // Move to the next record
   w["Next"]();
  }
}

See Also

BDE.CreateQuery
BDE.CreateStoredProc

Highlight search results