BDE Object

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

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.

The BDE object is a top-level object that is available only if the BDE plugin is installed.

The BDE Support plugin is not available in TestComplete 64-bit.
Just like the VCL classes, the BDE interfaces only work if the Borland Database Engine is installed.

Members

Example

The code below demonstrates how you can use the BDE technology in your tests. The routine creates a BDE table that holds 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