|
|
|
void Connect( const SAString &sDBString
, const SAString &sUserID , const SAString &sPassword
, SAClient_t eSAClient = SA_Client_NotSpecified );
throw (SAException);
Opens the connection to a data source.
Parameters
sDBString. Name of database this
connection will connect to (see Server specific notes).
sUserID. A string containing a user
name to use when establishing the connection (see Server
specific notes).
sPassword. A string containing a
password to use when establishing the connection.
eSAClient. Optional. One of the
following values from SAClient_t enum:
- SA_Client_NotSpecified
Used by default. Client is not specified.
- SA_Oracle_Client
Oracle client.
- SA_SQLServer_Client
SQL Server client.
- SA_InterBase_Client
InterBase client.
- SA_SQLBase_Client
SQLBase client.
- SA_ODBC_Client ODBC
client.
- SA_DB2_Client DB2
client.
- SA_Informix_Client
Informix client.
- SA_Sybase_Client Sybase
client.
- SA_MySQL_Client MySQL
client.
- SA_PostgreSQL_Client
PostgreSQL client.
- SA_SQLite_Client SQLite
client.
Remarks
Using the Connect method on a SAConnection
object establishes the physical connection to a data source. After this
method successfully completes, the connection is live and you can issue
commands against it and process the results.
If you use the default value of eSAClient
parameter, you should call setClient
method before using Connect.
To check whether a connection established use isConnected method.
Server specific notes
|
Oracle
|
sDBString - the database name as it is
specified in TNSNAMES.ORA file.
If sUserID parameter is empty, SQLAPI++
Library requests Oracle external authentication.
The SQLAPI++ Library requires OCI version 7.3 or higher.
The Library tries to connect to Oracle using OCI8 first. If it fails it
tries to connect using OCI7.
|
|
SQL Server
|
sDBString - one of the following formats:
- "" or "@" - empty string or '@'
character, connects to a default database on a local server.
- <database name> or @ <database
name> - connects to a database with the
specified name on your local server.
- <server name>@ - connects
to a default database on the specified server.
- <server name>@<database name> -
connects to a database with the specified name on the specified server.
To connect to a named instance of SQL Server 2000 use <server
name\instance name> instead of <server name>.
If sUserID parameter is empty, SQLAPI++
Library requests a secure, or trusted, connection to SQL Server.
Using OLE DB
Starting from version 3.3.1 SQLAPI++ Library uses OLE DB as the
default API when working with SQL Server. The SQLAPI++ Library
requires SQL Server OLE DB version 2.5 or higher.
Using DB-Library
Starting from version 3.3.1 SQLAPI++ Library uses OLE DB as the
default API when working with SQL Server. If you want to use
DB-Library, you should set "UseAPI" connection option before
specifying SQL Server client or connecting to database. The SQLAPI++
Library requires DB-Library version 6.x or higher.
|
| Sybase |
sDBString - one of the following formats:
- "" or "@" - empty
string or '@' character, connects to a default database on a default
server.
- <database name> or @ <database
name> - connects to a database with the
specified name on your default server.
- <server name>@ -
connects to a default database on the specified server.
- <server name>@<database name> -
connects to a database with the specified name on the specified server.
The SQLAPI++ Library requires Open Client version 10.0
or higher.
|
|
DB2
|
sDBString - any valid DB2 connection string.
The SQLAPI++ Library requires DB2 CLI version 6.x or
higher.
|
|
Informix
|
sDBString - any valid Informix connection
string.
The SQLAPI++ Library requires Informix CLI version 2.x
or higher.
|
|
InterBase
|
sDBString:
- For local InterBase databases, this can be a file
name.
- To connect to an InterBase database on a remote
server using TCP/IP the syntax is <server
name>:<filename>.
- To connect to an InterBase database on a remote
server using NetBEUI, the syntax is \\ <server
name>\<filename>.
- To connect to an InterBase database on a remote
server using SPX, the syntax is <server
name>@<filename>.
The SQLAPI++ Library requires client API version 5.x or
higher.
|
|
SQLBase
|
sDBString - the database name as it is
specified in SQL.INI file.
The SQLAPI++ Library requires CAPI version 6.x or higher.
|
|
MySQL
|
sDBString - One of the following formats:
- "" or "@" - empty string or '@'
character, connects to a local server.
- <database name> or @ <database
name>- connects to a database with the specified
name on local server.
- <server name>@- connects to
the specified server.
- <server name>@<database name> -
connects to a database with the specified name on the specified server.
<server name> in its turn can
have the following formats:
- hostname[:port]
- pathname of the Unix socket that is used to connect
to the server
The SQLAPI++ Library requires MySQL C API version 3.23.x
or higher.
|
|
PostgreSQL
|
sDBString - One of the following formats:
- "" or "@" - empty string or '@'
character, connects to a local server.
- <database name> or @ <database
name>- connects to a database with the specified
name on local server.
- <server name>@- connects to
the specified server.
- <server name>@<database name> -
connects to a database with the specified name on the specified server.
The SQLAPI++ Library requires libpq version 7.1.x or
higher.
|
|
ODBC
|
sDBString - any valid ODBC connection string.
The SQLAPI++ Library requires ODBC version 3.x or higher.
|
|
SQLite
|
sDBString - any
valid path to the SQLite database file. sUserID and sPassword
parameters aren't used.
The SQLAPI++ Library requires SQLite version 3.x or higher.
|
See also
isConnected, Disconnect, setClient, setOption
SAClient_t
Error handling
Problems and Questions
If you haven't found the answer to your questions or have
some problems on using the Library, please, send e-mail to howto@sqlapi.com.
|