c# - MySQL OdbcConnection Error System.Data.Odbc.OdbcException -
i trying connect mysql database using odbcconnection in c#. getting following error:
an unhandled exception of type 'system.data.odbc.odbcexception' occurred in system.data.dll
additional information:
error [im002] [microsoft][odbc driver manager] data source name not found , no default driver specified
what causing error?
here code:
string connectionstring = "driver=mysql odbc 5.2 unicode driver;server=myserver.com;database=mydb;user=myusername;password=mypassword;option=3;"; odbcconnection myodbcconnection = new odbcconnection(connectionstring); odbccommand cmd = new odbccommand(); odbcdatareader reader; cmd.commandtext = sql; cmd.commandtype = commandtype.text; cmd.connection = myodbcconnection; myodbcconnection.open(); reader = cmd.executereader(); myodbcconnection.close();
i have tried following connection strings:
"provider=msdasql;driver={mysql odbc 5.2 unicode driver};server=tcr.cjcresources.com;database=tcr;user=ahardin;password=go2sql!;option=3;"; "driver={mysql odbc 5.2 unicode driver};server=tcr.cjcresources.com;database=tcr;user=ahardin;password=go2sql!;option=3;"; "dsn={mysql odbc 5.2 unicode driver};server=tcr.cjcresources.com;database=tcr;user=ahardin;password=go2sql!;option=3;";
and many more like.
my setting control panel->administrative tools->data sources (odbc)
user dsn has: mysql odbc 5.2 unicode drive & mysql odbc 5.2 ansi drive
system dsn has: mysql odbc 5.2 unicode drive & mysql odbc 5.2 ansi drive
file dsn has: mysql odbc 5.2 unicode drive & mysql odbc 5.2 ansi drive in odbc folder
i have mysql workbench able connect remote database
any appreciated
"driver=mysql odbc 5.2 unicode driver;server=myserver.com;database=mydb;user=myusername;password=mypassword;option=3;"
should be
"driver={mysql odbc 5.2 unicode driver};server=myserver.com;database=mydb;user=myusername;password=mypassword;option=3;"
your driver name contains spaces delimit { , }. personally, odbc defined attributes, i'd use uppercase i've come across driver managers uppercase.
Comments
Post a Comment