Hi Everyone
I'm busy working on an ASP.NET Web Application (3.5) and can't seem to connect to a MySQL DB. I first created the entire application using a WinForms template and everything works 100%, but as soon as I move the exact same code to the Web Application, I can't connect anymore. Here's the code:
As soon as I try to create the new OdbcConnection instance, I get the error:
As noted this works in a WinForms app, and even more strange is that I don't even specify a DSN name...
All I could find from reading through forums all over the internet is suggestions of downgrading the MySQL ODBC driver version, which I'd really rather not...
Any ideas?
I'm busy working on an ASP.NET Web Application (3.5) and can't seem to connect to a MySQL DB. I first created the entire application using a WinForms template and everything works 100%, but as soon as I move the exact same code to the Web Application, I can't connect anymore. Here's the code:
Code:
public class DBC
{
OdbcConnection connection;
public bool CreateConnection()
{
try
{
string connFormat = "Driver={MySQL ODBC 5.1 Driver};Server=[SERVER];Database=[DBNAME];User=[UID];Password=[PWD];";
connFormat = connFormat.Replace("[SERVER]", Properties.Settings.Default.DBServer);
connFormat = connFormat.Replace("[DBNAME]", Properties.Settings.Default.DBName);
connFormat = connFormat.Replace("[UID]", Properties.Settings.Default.DBUser);
connFormat = connFormat.Replace("[PWD]", Properties.Settings.Default.DBPassword);
connection = new OdbcConnection(connFormat);
connection.Open();
return true;
}
catch (Exception ex)
{
return false;
}
}
Code:
ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
All I could find from reading through forums all over the internet is suggestions of downgrading the MySQL ODBC driver version, which I'd really rather not...
Any ideas?