BDE.CreateDatabase

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

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"]();
  };
}

Highlight search results