guaike
guaike

Reputation: 2491

How to set ODBC connection string for adaptive server anywhere network server in C#

I have a adaptive server anywhere network server(version 7.0),it's name is "TestServer". Now, Client want to connect this server using OdbcConnetion in DOTNET,How to set the connection string ?

Upvotes: 1

Views: 4487

Answers (2)

David Thielen
David Thielen

Reputation: 32904

For questions like this Connection Strings is your best resource.

Upvotes: 1

awe
awe

Reputation: 22442

The connection string for ODBC use DSN like this:

string connString = "DSN=TestServer;UID=user;PWD=password;";

Using DSN requires the client to set up the ODBC DSN on the client computer. Alternatively, you can include the driver details in the connection string if you know what ODBC driver the user has installed:

string connString = "{Microsoft ODBC for Oracle};SERVER=TestServer;UID=user;PWD=password;";

Then include the connection string in the creation of the OdbcConnection object:

System.Data.Odbc.OdbcConnection conn = new System.Data.Odbc.OdbcConnection(connString);

Or after:

System.Data.Odbc.OdbcConnection conn = new System.Data.Odbc.OdbcConnection();
conn.ConnectionString = connString;

Upvotes: 3

Related Questions