cancel
Showing results for 
Search instead for 
Did you mean: 

How to connect to a Sybase v5.0 server using ODBC + .net

Former Member
9,355

Hello, I have a old myDemo.db file, that was created from Sybase 5.0. I need to create a Windows app to access that DB, I have tried all possibles connections strings (using ODBC), but none worked.

I have installed the Sybase 5.0 server and client app, I created the server locally(by service manager) and I can access by ISQL, but when I try to access from a .net windows app, doesn't work.

Recently, I installed the Sybase latest version, but when I try to create the myDemo.db, using the Personal Server app, doesn't work. "myDemo.db was created by a different version of the software".

Can someone help ? What do I need to use to create the ODBC and connect to that database? Thanks

The error that I get, when trying to use ODBC:

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

Code

string conStr = "Driver={Sybase SQL Anywhere 5.0};Dsn=Prima;uid=dba;PWD=test";
OdbcConnection conn = new OdbcConnection(conStr);
conn.Open();

string sql = "select count(*) from ClienteCorretor";
OdbcCommand cmd = new OdbcCommand(sql, conn);
int result = cmd.ExecuteNonQuery();

if (conn.State != ConnectionState.Closed)
    conn.Close();

Accepted Solutions (1)

Accepted Solutions (1)

jeff_albion
Advisor
Advisor

This configuration will not work. The SQL Anywhere 5.5 ODBC driver (wod50t.dll) is only an ODBC 2.0 compliant driver and does not have an exported function SQLSetEnvAttr (available in ODBC 3.0). The ADO.NET OdbcConnection expects an ODBC 3.0-compatible driver.


Are you in a position to migrate your SQL Anywhere 5.5 to a higher SQL Anywhere database version? (This would also allow you to use our ADO.NET driver directly in .NET instead of trying to use OdbcConnection).

You really shouldn't be developing new applications on an unsupported database version as we will have limited options to help you if you run into other problems with this development process or while operating in prodcution.

VolkerBarth
Contributor

Just in case migrating the v5 database itself is not feasible: AFAIK, a v9 database server (which has a ADO.Net driver) would allow you to run that v5 database...

Former Member
0 Kudos

Volker, where can I find that version?

Former Member
0 Kudos

Thanks Jeff. I know that its an old version, but I have a windows app from another company that uses that version, and I'm developing a .net app to assist my client in their daily needs, that must access the same DB. Unfortunately i cant change it.

jeff_albion
Advisor
Advisor

The full version is no longer available for purchase (for production deployment), nor is the developer version (for testing). SQL Anywhere 9.0.x has been end-of-life'd. Also see this question here.

jeff_albion
Advisor
Advisor

In that case, you may have to change how you're planning to write your new program. If you need to stay with the SA 5.x engine / database, you'll be limited developing with an ODBC 2.0 interface with the SA 5.x ODBC driver - OdbcConnection can't use that.

If you really wanted to stay in .NET, this would mean you would have to write some kind of COM/Interop native C/C++ "wrapper" that makes only native ODBC 2.0 calls out to the SA 5.x ODBC driver (via pinvoke) and returns the data to the managed environment.

(i.e. You need to prevent all SQLSetEnvattr calls (and other ODBC 3.0 calls) against the ODBC driver).

Former Member
0 Kudos

So, I can't use the v9 to run the db from v5 =/. ty

Answers (0)