ISecurityConnection.CreateCommand

Syntax

CreateCommand(Sql: String): IDalCommand;

Parameters

Sql. SQL query that should be executed on database server.

Description

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

Example

Executing the example requires that the repository contains a database with the DB identifier.

Add links to the Dal and Metabase system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    DB: IDatabaseInstance;
    Connect: ISecurityConnection;
    Command: IDalCommand;
    Cur: IDalCursor;
    CurFields: IDalCursorFields;
    i: Integer;
Begin
    MB := MetabaseClass.Active;
    DB := MB.ItemById("DB").Open(NullAs 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 UserProc;

After executing the example a connection is established to the database server, to which the specified database is set up. The SQL query that gets all data from the table is created and executed for this connection. The obtained data is displayed in the development environment console.

See also:

ISecurityConnection