BDE Object

Applies to TestComplete 15.69, last modified on November 13, 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.

Description

The BDE object creates and accesses script objects that implement the same methods and properties as data-aware VCL objects for BDE access (databases, tables, queries, etc), by implementing OLE-interface analogues of these.

Requirements
  • The 32-bit version of TestComplete.

    The 64-bit version of TestComplete does not support the Borland Database Engine.

  • The BDE Support plugin must be enabled in TestComplete.

  • The Borland Database Engine must be installed on your computer.

Members

Example

The script sample below shows how to use the Borland Database Engine in tests. The script creates a BDE table that gets data from the Products table of the Northwind sample database that comes with Microsoft SQL Server.

JavaScript, JScript

function TestSQL_BDE()
{
  var aTable, S, i;
  // Create a table
  aTable = BDE.CreateTable();
  // Specify the database name
  aTable.DatabaseName = "MYSQL"; // <-- BDE alias
  // Specify the table name
  aTable.TableName = "Products";
  // Open the table
  aTable.Open();
  aTable.First();
  // Retrieve field names
  S = "";
  for (i = 0; i < aTable.FieldCount; i++)
    S = S + aTable.Field(i).FieldName + "\t";
  S = S + "\r\n";
  // Scan through dataset records
  while ( ! aTable.EOF)
  {
    for (i = 0; i < aTable.FieldCount; i++)
      S = S + aTable.Field(i).AsString + "\t";
    S = S + "\r\n";
    aTable.Next();
  };
  // Output results
  Log.Message("Products", S);
  // Close the table
  aTable.Close();
}

Python

def TestSQL_BDE():
  # Create a table
  aTable = BDE.CreateTable()
  # Specify the database name
  aTable.DatabaseName = "MYSQL" # <-- BDE alias
  # Specify the table name
  aTable.TableName = "Products"
  # Open the table
  aTable.Open()
  aTable.First()
  # Retrieve field names
  S = ""
  for i in range(0, aTable.FieldCount):
    S = S + aTable.Field(i).FieldName + "\t"
  S = S + "\r\n"
  # Scan through dataset records
  while not aTable.EOF:
    for i in range(0, aTable.FieldCount):
      S = S + aTable.Field(i).AsString + "\t"
    S = S + "\r\n"
    aTable.Next()
  # Output results
  Log.Message("Products", S)
  # Close the table
  aTable.Close()

VBScript

Sub TestSQL_BDE
  ' Create a table
  Set aTable = BDE.CreateTable
  ' Specify the database name
  aTable.DatabaseName = "MYSQL" ' <-- BDE alias
  ' Specify the table name
  aTable.TableName = "Products"
  ' Open the table
  aTable.Open
  aTable.First
  ' Retrieve field names
  S = ""
  For i = 0 To aTable.FieldCount - 1
    S = S + aTable.Field(i).FieldName + Chr(9)
  Next
  S = S + Chr(13) + Chr(10)
  ' Scan through dataset records
  Do While Not aTable.EOF
    For i = 0 To aTable.FieldCount - 1
      S = S + aTable.Field(i).AsString + Chr(9)
    Next
    S = S + Chr(13) + Chr(10)
    aTable.Next
  Loop
  ' Output results
  Log.Message "Products", S
  ' Close the table
  aTable.Close
End Sub

DelphiScript

procedure TestSQL_BDE;
var
  aTable, S, i : OleVariant;
begin
  // Create a table
  aTable := BDE.CreateTable;
  // Specify the database name
  aTable.DatabaseName := 'MYSQL'; // <-- BDE alias
  // Specify the table name
  aTable.TableName := 'Products';
  // Open the table
  aTable.Open;
  aTable.First;
  // Retrieve field names
  S := '';
  for i := 0 to aTable.FieldCount - 1 do
    S := S + aTable.Field(i).FieldName + Chr(9);
  S := S + Chr(13) + Chr(10);
  // Scan through dataset records
  while not aqConvert.VarToBool(aTable.EOF) do
  begin
    for i := 0 to aTable.FieldCount - 1 do
      S := S + aTable.Field(i).AsString + Chr(9);
    S := S + Chr(13) + Chr(10);
    aTable.Next;
  end;
  // Output results
  Log.Message('Products', S);
  // Close the table
  aTable.Close;
end;

C++Script, C#Script

function TestSQL_BDE()
{
  var aTable, S, i;
  // Create a table
  aTable = BDE["CreateTable"]();
  // Specify the database name
  aTable["DatabaseName"] = "MYSQL"; // <- BDE alias
  // Specify the table name
  aTable["TableName"] = "Products";
  // Open the table
  aTable["Open"]();
  aTable["First"]();
  // Retrieve field names
  S = "";
  for (i = 0; i < aTable["FieldCount"]; i++)
    S = S + aTable["Field"](i)["FieldName"] + "\t";
  S = S + "\r\n";
  // Scan through dataset records
  while ( ! aTable["EOF"])
  {
    for (i = 0; i < aTable["FieldCount"]; i++)
      S = S + aTable["Field"](i)["AsString"] + "\t";
    S = S + "\r\n";
    aTable["Next"]();
  };
  // Output results
  Log["Message"]("Products", S);
  // Close the table
  aTable["Close"]();
}

See Also

BDE Plugin
Working With Databases
TestComplete Helper Objects

Highlight search results