Dal > Dal Assembly Interfaces > IDalDriver > IDalDriver.CreateDescriptor
CreateDescriptor: IDalConnectionDescriptor;
The CreateDescriptor method creates a description of the database connection using this driver.
Executing the example requires a DBMS server based on Microsoft SQL Server. A database named WAREHOUSE is created on the server. The operating system, in which the example will be executed, has PostgreSQL ODBS driver installed. One can also create a custom DSN named PostgreSQL35W.
Add a link to the Dal system assembly.
Sub UserProc;
Var
Driver: IDalDriver;
ConDesc: IDalConnectionDescriptor;
ODBCConnection: IDalODBCConnectionDescriptor;
Connection: IDalConnection;
Begin
Driver := New DalODBCDriver.Create;
ConDesc := Driver.CreateDescriptor;
ODBCConnection := ConDesc As IDalODBCConnectionDescriptor;
/// <summary>
/// Below are various options of specifying connection parameters (1-3).
/// Each option is used independently of other options,
/// one can also use combination of options for setting parameters
/// using the ODBCParams and ODBCParamValue (4) property.
/// </summary>
// 1. Custom DSN
ODBCConnection.ODBCParams := "DSN=PostgreSQL35W";
// 2. Full connection string
ODBCConnection.ODBCParams := "DRIVER={PostgreSQL Unicode};SERVER=127.0.0.1;DATABASE=WAREHOUSE;UID=user;PWD=password;";
// 3. Set value of parameter named DSN or specific connection parameters
ODBCConnection.ODBCParamValue("DSN") := "PostgreSQL35W";
// or
ODBCConnection.ODBCParamValue("DRIVER") := "{PostgreSQL Unicode}";
ODBCConnection.ODBCParamValue("SERVER") := "127.0.0.1";
ODBCConnection.ODBCParamValue("DATABASE") := "WAREHOUSE";
ODBCConnection.ODBCParamValue("UID") := "user";
ODBCConnection.ODBCParamValue("PWD") := "password";
// 4. Combination of options
ODBCConnection.ODBCParams := "DRIVER={PostgreSQL Unicode};SERVER=127.0.0.1;DATABASE=WAREHOUSE";
ODBCConnection.ODBCParamValue("UID") := "user";
ODBCConnection.ODBCParamValue("PWD") := "password";
// Create a connection
Connection := ConDesc.CreateConnection;
Debug.WriteLine(Connection.IsDisconnected ? "No connection." : "Connection created.");
Connection.Close;
End Sub UserProc;
The example displays various options of setting connection settings using ODBC driver. To execute the example, select one option and comment the rest of the options, specify settings of real DBMS server.
See also: