BDE.CreateDatabase Method

Applies to TestComplete 15.40, last modified on July 05, 2022
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 CreateDatabase method creates an object of the IAQADatabase type (an analogue of the VCL TDatabase type).

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

Declaration

BDE.CreateDatabase()

Result An IAQADatabase object

Applies To

The method is applied to the following object:

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.

Example

The following code demonstrates how you can work with IAQADatabase objects in your scripts. This example requires that the local InterBase Server be running.

JavaScript, JScript

function TestProc()
{
  var d, w;
  d = BDE.CreateDatabase();
  d.DatabaseName = "MyDatabase";
  d.AliasName = "IBLOCAL";
  d.LoginPrompt = 0;
  d.Params = "USER NAME = SYSDBA" + "\r\n" + "PASSWORD=masterkey";
  d.Connected = 1;
  w = BDE.CreateTable();
  w.DatabaseName = "MyDatabase";
  w.TableType = 0;
  w.TableName = "EMPLOYEE";
  w.Open();
  w.First();
  while (!w.EOF)
  {
    Log.Message(w.FieldByName("First_Name").AsString);
    w.Next();
  }
}

Python

def TestProc():
  d = BDE.CreateDatabase()
  d.DatabaseName = "MyDatabase"
  d.AliasName = "IBLOCAL"
  d.LoginPrompt = 0
  d.Params = "USER NAME = SYSDBA" + "\r\n" + "PASSWORD=masterkey"
  d.Connected = 1
  w = BDE.CreateTable()
  w.DatabaseName = "MyDatabase"
  w.TableType = 0
  w.TableName = "EMPLOYEE"
  w.Open()
  w.First()
  while not w.EOF:
    Log.Message(w.FieldByName("First_Name").AsString)
    w.Next()

VBScript

Sub TestProc
  Set d = BDE.CreateDatabase
  d.DatabaseName = "MyDatabase"
  d.AliasName = "IBLOCAL"
  d.LoginPrompt = 0
  d.Params = "USER NAME = SYSDBA" + Chr(13) + Chr(10) + "PASSWORD=masterkey"
  d.Connected = True
  Set w = BDE.CreateTable
  w.DatabaseName = "MyDatabase"
  w.TableType = 0
  w.TableName = "EMPLOYEE"
  w.Open
  w.First
  While Not w.EOF
    Log.Message w.FieldByName("First_Name").AsString
    w.Next()
  WEnd
End Sub

DelphiScript

procedure TestProc;
var
  d, w: OleVariant;
begin
  d := BDE.CreateDatabase;
  d.DatabaseName := 'MyDatabase';
  d.AliasName := 'IBLOCAL';
  d.LoginPrompt := False;
  d.Params := 'USER NAME = SYSDBA' + #13#10 + 'PASSWORD=masterkey';
  d.Connected := True;
  w := BDE.CreateTable;
  with w do
  begin
    DatabaseName := 'MyDatabase';
    TableType := ttDefault;
    Tablename := 'EMPLOYEE'
  end;
  w.Open;
  w.First;
  while not aqConvert.VarToBool(w.EOF) do
  begin
   Log.Message(w.FieldByName('First_Name').AsString);
   w.Next;
  end;
end;

C++Script, C#Script

function TestProc()
{
  var d, w;
  d = BDE["CreateDatabase"]();
  d["DatabaseName"] = "MyDatabase";
  d["AliasName"] = "IBLOCAL";
  d["LoginPrompt"] = 0;
  d["Params"] = "USER NAME = SYSDBA" + "\r\n" + "PASSWORD=masterkey";
  d["Connected"] = 1;
  w = BDE["CreateTable"]();
  w["DatabaseName"] = "MyDatabase";
  w["TableType"] = 0;
  w["TableName"] = "EMPLOYEE";
  w["Open"]();
  w["First"]();
  while (!w["EOF"])
  {
    Log["Message"](w["FieldByName"]("First_Name")["AsString"]);
    w["Next"]();
  };
}

See Also

BDE.GetDatabase

Highlight search results