Reputation: 1526
I have a control which requires SQCN connection. So I supplied it with proper credentials and there's nothing wrong with it.
string connection = "Data Source=(local);Initial Catalog=test;user ID=sa; Password=sa12345;";
SqlConnection sqcn = new SqlConnection(connection);
sqcn.Open();
Now due to requirements I need to change the dbConnection from SqlConnection to OdbcConnection. I used the same connection and replace Sql with Odbc but it shows an error
string connection = "Data Source=(local);Initial Catalog=test;user ID=sa; Password=sa12345;";
OdbcConnection odbc= new OdbcConnection(connection);
odbc.Open();
ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
Can someone pls tell me if im missing something.. Tnx!
Upvotes: 0
Views: 578
Reputation: 32511
You should install the proper driver for ODBC and define the data source. You can see data sources in administrative tools -> ODBC Data Source, also you can define data source here and reference it in your program via its Name.
Upvotes: 1