D3 developers should review the following considerations when using ADO.
Currently, the OLE DB Provider for ODBC is the only means by which an ADO-based application can connect to a D3 database. In the future, a native OLE DB Provider for D3 will be available.
Applications developed using the OLE DB Provider for ODBC will also run with the native provider with only minor modification to the application.
There are two types of connection strings available for making a connection to a D3 database:
a string that specifies an existing ODBC DSN
a string that specifies an ODBC driver
Both of these options are described below.
To use an existing ODBC DSN, include the string DSN= and the DSN name in the ConnectionString property of the ADO Connection object. For example, a line of code in Visual Basic might look like this:
oConn.ConnectionString = "PROVIDER=MSDASQL;DSN=sqldemo"
The DSN, sqldemo, contains all the necessary information to connect to the D3 database.
To specify an ODBC file DSN, use the keyword, FILEDSN, such as,
oConn.ConnectionString = "PROVIDER=MSDASQL;FILEDSN=fsqldemo"
Instead of using an ODBC DSN, all the connection information can be included in the connection string itself. To connect to a D3 database, the connection string must include the keywords below:
Required Keywords | Description |
---|---|
DRIVER | Use {D3 ODBC Driver}. |
SERVER | Host name of the machine where the D3 ODBC server is running. |
VIRTUALMACHINE | Name of the D3 virtual machine or Unix servers, this is typically pick0 or Windows servers, this is the name of the machine where the primary VME resides. |
PORTNUMBER | TCP port number where the D3 ODBC server is listening; by default, 1603. |
UID | D3 user |
ACCOUNT | D3 account |
D3VERSION | Use 710 |
For example, a line of code in C++ might look like this:
pConn->Open("PROVIDER=MSDASQL;DRIVER={D3 ODBC Driver};SERVER=prod; VIRTUALMACHINE=pick0;PORTNUMBER=1603;UID=dm;ACCOUNT=sqldemo; D3VERION=710;");
Optional keywords for use in the connection string are described below:
Optional Keywords | Description |
---|---|
PWD | D3 user password |
ACPASSWORD | D3 account password |
CONNECTDIALOG | Yes to force a dialog box at connection time. |
For example, to prompt for passwords at connection time, include the CONNECTDIALOG keyword as shown below:
pConn->Open("PROVIDER=MSDASQL;DRIVER={D3 ODBC Driver};SERVER=prod; VIRTUALMACHINE=pick0;PORTNUMBER=1603;UID=dm;ACCOUNT=sqldemo; D3VERSION=710;CONNECTDIALOG=YES");
As with D3 ODBC, only forward-only and static cursors are available in ADO-based applications. If a dynamic or keyset cursor is requested, a static cursor is returned. The location of the cursor should typically be set to adUseServer.
Pessimistic locking is not available. If the LockType is set to adLockPessimistic, the option is set but ignored. Query-based updates use an optimistic, by-value scheme.
Since asynchronous execution is not supported in D3 ODBC, applications developed with ADO run with synchronous query execution.
If a recordset is opened with a static cursor and the SQL statement is not successfully executed, the error returned is –2147217887. "The request properties can not be supported by this ODBC Driver", rather than the expected error –21472179000 "The command contains one or more errors".
The REQUERY method should not be used in a program that involves transactions. To update the data in a recordset, the recordset should be closed (using CLOSE) and re-opened (using OPEN).