ISecurityConnection.CreateCommand

Syntax

CreateCommand(Sql: String): IDalCommand;

Parameters

Sql - SQL query that should be executed on DB server.

Description

The CreateCommand method creates a new object used for working with DB by means of SQL queries.

Example

Sub Main;

Var

MB: IMetabase;

DB: IDatabaseInstance;

Connect: ISecurityConnection;

Command: IDalCommand;

Cur: IDalCursor;

CurFields: IDalCursorFields;

i: Integer;

Begin

MB := MetabaseClass.Active;

DB := MB.ItemById("BD").Open(Null) As IDatabaseInstance;

Connect := DB.Connection;

Command := Connect.CreateCommand("Select * From Table_1");

Cur := Command.CreateCursor;

While Not Cur.Eof Do

CurFields := Cur.Fields;

For i := 0 To CurFields.Count - 1 Do

Debug.Write(CurFields.Item(i).Value);

Debug.Write(" ");

End For;

Debug.WriteLine("");

Cur.Next;

End While;

Cur.Close;

End Sub Main;

After executing the example the connection to the DB server, on which the BD repository database is configured, is established. The SQL query that gets all data from the Table_1 table is created and executed for this connection. The obtained data is displayed in the development environment console.

See also:

ISecurityConnection