Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 42215

VS 2008 ODBC Connection to local MySQL DB throws "Datasource Name not Found"

$
0
0
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:

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;
            }
        }

As soon as I try to create the new OdbcConnection instance, I get the error:
Code:

ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
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?

Viewing all articles
Browse latest Browse all 42215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>