Applies to TestComplete 14.30, last modified on November 21, 2019

The following code uses the BDE.CreateTable method to access a database and copy one field from each record 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 go 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"]();
  }
}

Highlight search results