Connecting to Database

This topic describes the procedure of connecting to databases with different providers, and meaning of connection parameters.

Common connection properties

Each database server requires its own set of parameters for connection (username, password, etc.). Some of the parameters are the same for several servers, but the parameter meaning may vary depending on the server. UniDAC provides all types of parameters for supported database servers. If a parameter is not used for a certain provider, it will be disabled in the connection dialog and not used for connection. UniDAC supports the following parameters:


This is the first parameter that should be set. It specifies the provider that will be used for connection, and other parameters that will be available.

Username and Password

These properties are used for each database provider to authenticate the client application.


Commonly this property is used to provide the name or the IP address of the computer in the network on which the database sever is located. If the Server property is empty for SQL Server, MySQL, and InterBase providers, UniDAC will try to connect to localhost.


This property is used for Access, Advantage, SAP Sybase ASE, DBF, InterBase, MySQL, NexusDB, PostgreSQL, SQL Server, and SQLite providers. It specifies initial database for the connection. On SAP Sybase ASE, MySQL, and SQL Server the Database value can be changed when the connection is active without reconnect. If the Database is not assigned, the behaviour of UniDAC will depend on the selected provider:


This property is used for SAP Sybase ASE, MySQL, and PostgreSQL providers. It specifies the port number for TCP/IP connection.

Provider-specific properties

Along with the connection options described above, there are several specific options that manage connection behaviour for each provider. These options are described in the Provider-specific Notes articles for each provider: Oracle, SQL Server, MySQL, InterBase, PostgreSQL, and SQLite. Open the article that corresponds to the provider you are interested in, and find the specific options description for TUniConnection in the article. Several important specific connection options will be described below.


With the Oracle provider you can connect to the server in two modes: the Client mode, and the Direct mode. Connecting in the Client mode requires Oracle client to be installed on the client computer. Connecting in the Direct mode does not require Oracle client, however, this mode has certain limitations. For more information, refer to the Connecting in Direct mode section in the article Using UniDAC with Oracle.

SQL Server

The SQL Server provider can connect through one of the three client types that can be changed using the OLEDBProvider specific option of TUniConnection. By default this option is set to prAuto. This value means that the provider will try to open the SQL Native Provider first. If this provider is not available, the OLE DB provider will be opened. In order to connect to SQL Server Compact Edition, the OLEDBProvider option must be set to prCompact. This value gives effect to all specific options which names start with Compact. The version of SQL Server Compact Edition to be used should be specified in the CompactVersion specific option. By default version of SQL Server Compact Edition will be chosen in accordance with the database file version. If the file does not exist, or the file is not a valid database file, the CompactVersion option will be used to determine which server version to load.


The MySQL provider can connect to MySQL server directly or using the client library libmysqld.dll. This behaviour is controlled by the Direct specific option. By default, Direct is set to True. If you switch Direct to False, you will need to deploy libmysqld.dll with your application.

In order to connect to a database with MySQL Embedded server, you should switch the value of the Embedded specific option to True. Its default value is False. If Embedded is set to True, the value of Direct is ignored. The Embedded Server library with the share directory should be deployed with the application. The path to data should be specified in the configuration file of Embedded Server.


The InteBase provider can connect to the server through such network protocols as TCP/IP, NetBEUI, and SPX. The network protocol that will be used for the connection can be specified with the Protocol specific option.


The PostgreSQL provider connects to PostgreSQL server directly and does not use the PostgreSQL client library.


The SQLite provider can connect to DB using SQLite client library SQLite3. You can use either an external SQLite3 library or embedded SQLite3 engine.This behaviour is controlled by theoption. By default Direct is set to False and in this case the SQLite provider searches a client library in directories specified in the PATH environment variable. SQLite can create the database file automatically if it does not exist. For this the ForceCreateDatabase specific option should be used.

© 1997-2022 Devart. All Rights Reserved. Request Support DAC Forum Provide Feedback