BDE.CreateDatabase Method

Applies to TestComplete 14.71, last modified on April 22, 2021

Description

Creates a new 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 for scripts as a TDatabase object does 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