BDE.CreateTable

Applies to TestComplete 15.62, last modified on March 19, 2024
Accessing databases by using the Borland Database Engine (BDE) is deprecated. Do not use it to create new tests. It will be removed from the product in one of the future releases. As an alternative, you can access databases by using the Microsoft Active Data Object (ADO). See Using ADO Components.

The following script sample uses the BDE.CreateTable method to access a database and copy a 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