A problem for ODBC.net, who could help me?
I'm trying to do simple connection with my database using ODBC.NET.
For that, I have created a very simple ASP.NET application under
Visual Studio.NET and I have placed the following code under a
button's onclick event.
---------
OdbcConnection cn;
OdbcCommand cmd;
string MyString;
MyString="Select * from table_name";
cn= new OdbcConnection("dsn=DSN_Name;UID=dba;PWD=sql;");
cmd=new OdbcCommand(MyString,cn);
try
{
cn.Open();
EnvMessage.Text = "Connected..";
}
catch(Exception ex)
{
EnvMessage.Text = "Failied. " + ex.ToString();
}
cn.Close();
-----------
table_name - I'm using a valid database table name.
DSN_Name - I'm using a valid DSN name that I have been using for my
windows application.
I'm getting the following errror.
------
Microsoft.Data.Odbc.OdbcException: ERROR [IM002] [Microsoft][ODBC
Driver Manager]
Data source name not found and no default driver specified at
Microsoft.Data.Odbc.OdbcConnection.Open()
at DSCOdbcConnection.WebForm1.Connect_Click(Object sender, EventArgs
e)
in c:\inetpub\wwwroot\dscodbcconnection\webform1.aspx.cs:line 96
------
If I create a Windows application instead of ASP.NET application, it
works just fine. It's connected with database. But ASP.NET application
throws the above error message.
Any help? I appreciate your help.
I'm here using DSN method to connect. Please help with correct
connection string.