Error:Data source name not found and no default driver specified

Padmanabhan, Venkatesh 120 Reputation points
2023-02-27T07:00:20.5166667+00:00

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()
}
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,246 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,203 questions
{count} votes