I have an app that is supposed to let the user choose between a MySQL
or MS SQL
connection.
I set the connection string like so:
OdbcConnection SqlConn = new OdbcConnection();
connString = String.Format("Driver={{{0}}}; Server={1}; Port={2}; DataBase={3}; Uid={4}; Pwd={5};", protocol, hostname, port, database, user, password);
SqlConn.ConnectionString = connString;
However, when attempting to open
the connection, I get the following error:
ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
Now, I tested a MySQLConnection instead and took our the Driver
part of the connection string and everything works fine. I'm sure it's something to do with the Driver
, but I'm not sure what. Most examples I see use Driver={MySQL}
, but that didn't work for me.
Note: Not sure if it matters, but the user is going to be selecting a radio button to determine if MySQL or MS SQL will be used.