Error:Data source name not found and no default driver specified
Padmanabhan, Venkatesh
120
Reputation points
Hi.
I am trying to connect to IBM DB2 database from my asp.net c# web application.
I have added the IBM.Data.db2.iSeries from the Manage nuget package, which in turn added the ibm.data.db2 in the reference. I added the connection string in web.config as below, and i tried 2 ways to open the database, but getting error as :
ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
I have checked : https://www.c-sharpcorner.com/UploadFile/nipuntomar/connection-strings-for-ibm-db2/
How to fix this ? How to connect to the DB2 database.
<connectionStrings>
<add name="dbconnection" connectionString="Database=DBNAMe;Hostname=hostname;Port=xxx;Uid=user id;Pwd=password;" />
</connectionStrings>
Method 1:
string constr = ConfigurationManager.ConnectionStrings["dbconnection"].ConnectionString;
using (OdbcConnection odbcConnection = new OdbcConnection(constr))
{
odbcConnection.Open();
}
Method 2:
using (iDB2Connection con = new iDB2Connection(constr))
{
con.Open()
}
Sign in to answer