DB.CreateConnection

Top  Previous  Next

 

Syntax

function DB.CreateConnection(ConType: integer; ConParams: string): pointer

 

Alternative Names

ibec_CreateConnection

 

Description

Create a new Connection object and returns a pointer to it that can be used in additional routine calls. If connection failed, NULL is returned.

 

ConType is one of the following constants:

 

__ctODBC

ODBC connection, ConParams is a data source name and optional username/password.

__ctADO

ADO connection, ConParams is an ADO connection string.

__ctFirebird

Firebird connection, ConParams has database connection string and additional details.

__ctInterBase

InterBase connection, ConParams has database connection string and additional details.

__ctMySQL

MySQL connection, ConParams has a database name and additional details.

 

ConParams depends on the database connection type and is a combination of name=value pairs.

 

ODBC

database|dbname=(database);[username=(username)];[password=(password)]

 

Database should be the name of an ODBC data source.

 

Username and password are optional, depending on the data source.

 

ADO

database|dbname=(connectstring)

 

Database should be the complete connect string.

 

Firebird/InterBase

database|dbname=(database);[username=(username)];[password=(password)][clientlib=(path_to_clientlib)][names=(charset_name)][sqldialect=1|3]

 

Database is a connection string with server, optional port, and database path. Additional options are available.

 

MySQL

database|dbname=(database);[username=(username)];[password=(password)]

 

Database is a server:database name.

 

See Also

DB.CreateConnection
DB.GetDefaultConnection
DB.UseDefaultConnection

 

Example

execute udsblock

as

begin

  connectstr = 'database=server_fb:c:\data\testdb.fdb;username=SYSDBA;password=masterkey;

                client_library=C:\Program Files (x86)\Firebird\Firebird_4_0\fbclient.dll';

 

  FBCon = DB.CreateConnection(__ctFirebird, connectstr);

 

  DB.UseConnection(FBCon);

  try

    /* perform queries */

  finally

    DB.CloseConnection(FBCon);

  end

end