adoConnOpen
Previous Topic  Next Topic 

Synopsis:

       adoConnOpen(handle,UID,PWD,conn_str1[,conn_str2...])

Arguments:

       handle                - The connection handle.

       UID                        - The user ID (can be left blank if it appears in the connection string)

       PWD                        - The password (can be left blank if it appears in the connection string)

       conn_str1                 - The first part of the connction string

       [conn_str2..]        - (optional) The remainder of the connection string across the remaining arguments.


Description:   This function attempts to open a connection on the given handle using the user id (UID), password (PWD), and connection string (conn_str1, con_str2....) provided.          


Note that this function will block the calling task, unless block mode is switched off using adoblockMode(), and will remain blocked until the connection completion event is received,  after which the task is woken up again with the appropriate return code.      Please make sure you are aware of performace issues that may arise with this function (see Performance and blocking calls).


The UID and PWD are optional arguments that can specify the login user ID and password for the data source.     Alternativly these can be specified driectly inside the connection string.


The remaining arguments are concatenated into a single connection string (but must not exceed 2047 characters).      For example in the following connection string is made up from a number of arguements that have been concatenated together in this way:



userID="postgres"

Passwd="admin"

Datasource="MyDSN";

Provider="MSDASQL.1"


     x=adoConnOpen(handle, "","", "Provider=",Provider,"; User ID=",userID,"; Password=",Passwd,"; Data Source=",Datasource);

     etc.


This is equivalent to :

     x=adoConnOpen(handle,"","2,"Provider=MSDASQL.1;Password=admin;User ID=postgres;Data Source=MyDSN");



Which is also equivalent to:


userID="postgres"

Passwd="admin"

   

        x=adoConnOpen(handle,userID,Passwd, "Provider=MSDASQL.1;Data Source=MyDSN"); Source=",Datasource);



The connection string that is used will depend upon the data source provider and will differ from source to source.   Below are some examples of connection strings for different kinds of data sources:


Oracle using Microsoft OLE provider:


"Provider=msdaora;Data Source=MyOracleDB;User Id=myUsername;Password=myPassword;"


Microsoft SQL server native client  10.0 OLE DB provider:


"Provider=SQLNCLI10;Server=myServerAddress;Database=myDataBase;Uid=myUsername; Pwd=myPassword;"


Microsoft Access Database using ACE OLE DB 12.0:


"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\myFolder\myAccess2007file.accdb;Jet OLEDB:Database Password=MyDbPassword";


A comprehensive list of connection strings for different data sources can be found here:


http://www.connectionstrings.com



Returns:   Returns 0 upon success or a negative error code.   If ADOERR_COMERR is returned, then the underlying ADO error can be obtained by calling adoLastError()