CreateCommand(Sql: String): IDalCommand;
Sql is the SQL query that has to be executed on the DB server.
The CreateCommand method creates a new object, used for working with the DB by SQL-queries.
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 connection to the DB server, on which the BD repository database is set, is performed. The SQL query, that extracts all data from the "Table_1" table, is created and executed for this connection. Obtained data is displayed in a development environment console.
See also: