I'm trying to write a tool in c# which will connect to Oracle database and I'm required to use ODBC.
If I use the following code:
using System.Data.Odbc;
string str1 = "DATA SOURCE=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=abcd.efgh.net)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=service_name)));USER ID=user_id;PASSWORD=qassword";
OdbcConnection coon = new OdbcConnection();
coon.ConnectionString = str1;
coon.Open();
I get the error message:
An unhandled exception of type 'System.Data.Odbc.OdbcException' occurred in System.Data.dll
Additional information: ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
even if I change the connection string to:
string str2 = "Driver={Oracle in OraClient12home1};DATA SOURCE=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=abcd.efgh.net)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=service_name)));USER ID=user_id;PASSWORD=qassword";
I get the same error message. So I guess the problem is not the "Driver = {...}" part? But what did I get wrong in the "DATA SOURCE" part?
Thank you.