[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

how to get connection string on aspx page from web.config file using mysql odbc driver?

Posted on 2008-11-04
7
Medium Priority
?
4,054 Views
Last Modified: 2013-12-17
settings in web.config
<connectionStrings>
    <add name="Connection" connectionString="Driver={MySQL ODBC 3.51 Driver};datasource=mySQL;database=;uid=;password=" providerName ="System.Data.Odbc"/>
   </connectionStrings>

Code in aspx.cs page to connect to web.config connection string
 string ConnStr = System.Configuration.ConfigurationManager.ConnectionStrings["Connection"].ToString() ;

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!
0
Comment
Question by:bschave2
  • 4
  • 3
7 Comments
 
LVL 21

Expert Comment

by:silemone
ID: 22881741
Here is a great site:  http://www.connectionstrings.com/

Pick the server you're using...most likely Sql Server 2005 and see how all the connect strings are built...
0
 
LVL 21

Expert Comment

by:silemone
ID: 22881748
are you using a mySql DB?
0
 

Author Comment

by:bschave2
ID: 22881766
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.
0
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 
LVL 21

Expert Comment

by:silemone
ID: 22881824
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,
0
 

Author Comment

by:bschave2
ID: 22881843
right, but I need the code to reference the connection string on my pages.
0
 
LVL 21

Accepted Solution

by:
silemone earned 2000 total points
ID: 22886387
pls explain because that's what this does:

 string ConnStr = System.Configuration.ConfigurationManager.ConnectionStrings["Connection"].ToString() ;

Maybe you post more code...what do yo mean by 'I need the code to reference the connection string on my pages'
0
 

Author Closing Comment

by:bschave2
ID: 31513333
the string was incorrect. it didn't support the string from the web.config file. correct code is


  OdbcConnection con = new OdbcConnection(System.Configuration.ConfigurationManager.ConnectionStrings["Connection"].ToString());
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
In this article, we’ll look at how to deploy ProxySQL.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month19 days, 5 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question