How to set ODBC connection string for adaptive server anywhere network server in C#
-
05-07-2019 - |
Question
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 ?
Solution
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;
OTHER TIPS
For questions like this Connection Strings is your best resource.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow