Unable to get {Watcom 4.0 SQL (ODBC 2.)} driver to connect with .NET 2.0 / C# /System.Data.Odbc

Having gotten System.Data.Odbc connections to work with Access, I've turned to trying to connect to a old legacy application using Watcom. I have successfully used the VS 2005 Data Connection wizard for Server Explorer to access the database and do table reads.

I'd like to replace some previous C# code with the Access ODBC driver by that for Watcom.

The settings for the Watcom driver in the WinXP ODBC Adminstrator are as follows...

Driver – "Watcom SQL 4.0 (ODBC 2.0)"

Data Source Name – "TestDB"

Description – ""

User ID – "dba"

Password – "sql"

Server Name – "TESTSERVER"

Database Alias – ""

Database File – "C:\app\TestBD.db"

Custom – checked (enabled), leading to..

Start Command – "dbeng40 –c32M"

Database Switches – ""

Autostop Database – checked (enabled)

Translator Name - "<no translator>"

Microsoft Applications – checked (enabled)

Prevent Driver not Capable errors – unchecked

Delay Autocommit - unchecked

ODBC Adminstrator Drivers tab reports this as...

Name - "Watcom SQL 4.0 (ODBC 2.0)"

Version - 5.00.00.00

File - WOD40T20.dll

File Date - 7/24/2001

I had seen a Watcom 5.0 string at www.connectionstrings.com, and tried that first. By removing an initial "ODBC" parameter, I came close. Same thing with trying a DSN connection string.

The code and error messages are as follows for the DSN version, followed by the "verbose" Watcom 5.0 -like version...

private void LoadDatabaseOdbc()

{

string sConnectString = "Dsn=TestDB;uid=dba;pwd=sql";

string sPerson = "";

// create a new OdbcDbConnection object

OdbcConnection odbcConn = new OdbcConnection(sConnectString);

// open the connection

odbcConn.Open();

// create the command object

OdbcCommand odbcComm = new OdbcCommand(

"SELECT PERSON FROM TESTTABLE", odbcConn);

// read the data sequentially and store the row in Arezzo

OdbcDataReader r = odbcComm.ExecuteReader();

while (r.Read())

{

// get values

sPerson = (string)r["Person"];

...

}

// close the reader

r.Close();

// close the connection

odbcConn.Close();

}

ERROR [08001] [WATCOM][ODBC Driver]Unable to connect to database server: unable to start specified database
ERROR [01000] [Microsoft][ODBC Driver Manager] The driver doesn't support the version of ODBC behavior that the application requested (see SQLSetEnvAttr).
ERROR [08001] [WATCOM][ODBC Driver]Unable to connect to database server

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.Odbc.OdbcException: ERROR [08001] [WATCOM][ODBC Driver]Unable to connect to database server: unable to start specified database
ERROR [01000] [Microsoft][ODBC Driver Manager] The driver doesn't support the version of ODBC behavior that the application requested (see SQLSetEnvAttr).
ERROR [08001] [WATCOM][ODBC Driver]Unable to connect to database server

[OdbcException (0x80131937): ERROR [08001] [WATCOM][ODBC Driver]Unable to connect to database server: invalid database engine command line
ERROR [01000] [Microsoft][ODBC Driver Manager] The driver doesn't support the version of ODBC behavior that the application requested (see SQLSetEnvAttr).
ERROR [08001] [WATCOM][ODBC Driver]Unable to connect to database server]
   System.Data.Odbc.OdbcConnection.HandleError(OdbcHandle hrHandle, RetCode retcode) +35
   System.Data.Odbc.OdbcConnectionHandle..ctor(OdbcConnection connection, OdbcConnectionString constr, OdbcEnvironmentHandle environmentHandle) +131
   System.Data.Odbc.OdbcConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject) +98
   System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup) +27
   System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +47
   System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +105

string sConnectString = "Driver={Watcom SQL 4.0 (ODBC 2.0)}; DefaultDir=C:\\app\\;Dbf=C:\\TestDB.db;Uid=dba;Pwd=sql;Dsn=\"\"";

ERROR [08001] [WATCOM][ODBC Driver]Unable to connect to database server: unable to start database engine
ERROR [01S00] [WATCOM][ODBC Driver]Invalid connection string attribute
ERROR [01000] [Microsoft][ODBC Driver Manager] The driver doesn't support the version of ODBC behavior that the application requested (see SQLSetEnvAttr).
ERROR [08001] [WATCOM][ODBC Driver]Unable to connect to database server

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.Odbc.OdbcException: ERROR [08001] [WATCOM][ODBC Driver]Unable to connect to database server: unable to start database engine
ERROR [01S00] [WATCOM][ODBC Driver]Invalid connection string attribute
ERROR [01000] [Microsoft][ODBC Driver Manager] The driver doesn't support the version of ODBC behavior that the application requested (see SQLSetEnvAttr).
ERROR [08001] [WATCOM][ODBC Driver]Unable to connect to database server

Clearly the "automated" way is doing something right in dealing with a pre-ODBC 3.0 that deals with SQLSetEnvAttr.

Any thoughts are appreciated!



Answer this question

Unable to get {Watcom 4.0 SQL (ODBC 2.)} driver to connect with .NET 2.0 / C# /System.Data.Odbc

  • Unable to get {Watcom 4.0 SQL (ODBC 2.)} driver to connect with .NET 2.0 / C# /System.Data.Odbc