bschave2
asked on
how to get connection string on aspx page from web.config file using mysql odbc driver?
settings in web.config
<connectionStrings>
<add name="Connection" connectionString="Driver={ MySQL ODBC 3.51 Driver};datasource=mySQL;d atabase=;u id=;passwo rd=" providerName ="System.Data.Odbc"/>
</connectionStrings>
Code in aspx.cs page to connect to web.config connection string
string ConnStr = System.Configuration.Confi gurationMa nager.Conn ectionStri ngs["Conne ction"].To String() ;
I am getting this error message
ERROR [HY000] [MySQL][ODBC 3.51 Driver]Can't connect to MySQL server on 'localhost' (10061)
ERROR [HY000] [MySQL][ODBC 3.51 Driver]Can't connect to MySQL
help is greatly appreciated!
<connectionStrings>
<add name="Connection" connectionString="Driver={
</connectionStrings>
Code in aspx.cs page to connect to web.config connection string
string ConnStr = System.Configuration.Confi
I am getting this error message
ERROR [HY000] [MySQL][ODBC 3.51 Driver]Can't connect to MySQL server on 'localhost' (10061)
ERROR [HY000] [MySQL][ODBC 3.51 Driver]Can't connect to MySQL
help is greatly appreciated!
are you using a mySql DB?
ASKER
yes, mysql driver to get to mysql db. the link above is for connection strings only. I have the connection string, but noo way to connect to the string on my asp page.
found someone with a same problem:
"I discovered that the cause of the problem was my using ODBC driver instead of MySQL Connector; apparently my ISP does not support ODBC. Also I was using
I rewrote the connection string in my web.config file and now my application works."
Regards,
"I discovered that the cause of the problem was my using ODBC driver instead of MySQL Connector; apparently my ISP does not support ODBC. Also I was using
I rewrote the connection string in my web.config file and now my application works."
Regards,
ASKER
right, but I need the code to reference the connection string on my pages.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
the string was incorrect. it didn't support the string from the web.config file. correct code is
OdbcConnection con = new OdbcConnection(System.Conf iguration. Configurat ionManager .Connectio nStrings[" Connection "].ToStrin g());
OdbcConnection con = new OdbcConnection(System.Conf
Pick the server you're using...most likely Sql Server 2005 and see how all the connect strings are built...