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. |
The following script sample shows 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"]();
};
}