BDE.GetDatabase Method

Applies to TestComplete 15.70, last modified on December 17, 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 GetDatabase method returns an IAQADatabase object previously created by the BDE.CreateDatabase method.

Declaration

BDE.GetDatabase(DatabaseName)

DatabaseName [in]    Required    String    
Result An IAQADatabase object

Applies To

The method is applied to the following object:

Parameters

The method has the following parameter:

DatabaseName

The name of the existing database that you want to get.

Result Value

An object of the IAQADatabase type.

Remarks

The IAQADatabase object provides the same functionality as the TDatabase object in VCL applications. It implements the same methods and properties, under the same names. See the VCL documentation for TDatabase.

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

Example

The code below obtains an existing database by its name and then posts the values of its VendorName field to the test log.

JavaScript, JScript

function GetDatabaseDemo()
{
  // Obtains the object corresponding to the database
  var Database = BDE.GetDatabase("DBDEMOS");
  // Opens the database
  Database.Open();
  // Moves to the first record
  Database.First();
  // Iterates through all records and
  // posts the value of the VendorName field to the test log
  while (! Database.EOF() )
  {
    // Inserts a message into the test log
    Log.Message(Database.FieldByName("VendorName").AsString);
    // Moves to the next record
    Database.Next();
  }
}

Python

def GetDatabaseDemo():
  # Obtains the object corresponding to the database
  Database = BDE.GetDatabase("DBDEMOS")
  # Opens the database
  Database.Open()
  # Moves to the first record
  Database.First()
  # Iterates through all records and 
  # posts the value of the VendorName field to the test log
  while not Database.EOF():
    # Inserts a message into the test log
    Log.Message(Database.FieldByName("VendorName").AsString)
    # Moves to the next record
    Database.Next()

VBScript

Sub GetDatabaseDemo

  ' Obtains the object corresponding to the database
  Set Database = BDE.GetDatabase("DBDEMOS")
  ' Opens the database
  Database.Open
  ' Moves to the first record
  Database.First
  ' Iterates through all records and
  ' posts the value of the VendorName field to the test log
  While Not Database.EOF
    ' Inserts a message into the test log
    Log.Message Database.FieldByName("VendorName").AsString
    ' Moves to the next record
    Database.Next
  Wend

End Sub

DelphiScript

function GetDatabaseDemo;
var Database;
begin
  // Obtains the object corresponding to the database
  Database := BDE.GetDatabase('DBDEMOS');
  // Opens the database
  Database.Open();
  // Moves to the first record
  Database.First();
  // Iterates through all records and
  // posts the value of the VendorName field to the test log
  while (not Database.EOF() ) do
  begin
    // Inserts a message into the test log
    Log.Message(Database.FieldByName('VendorName').AsString);
    // Moves to the next record
    Database.Next();
  end;
end;

C++Script, C#Script

function GetDatabaseDemo()
{
  // Obtains the object corresponding to the database
  var Database = BDE["GetDatabase"]("DBDEMOS");
  // Opens the database
  Database["Open"]();
  // Moves to the first record
  Database["First"]();
  // Iterates through all records and
  // posts the value of the VendorName field to the test log
  while (! Database["EOF"]() )
  {
    // Inserts a message into the test log
    Log["Message"]( Database["FieldByName"]("VendorName")["AsString"] );
    // Moves to the next record
    Database["Next"]();
  }
}

See Also

BDE.CreateDatabase

Highlight search results