We help IT Professionals succeed at work.

Connect to MySQL Database

REA_ANDREW
REA_ANDREW asked
on
Medium Priority
182 Views
Last Modified: 2008-03-03
I am reading up on this and cannot seem to get it right.

I am sure there is an oleDB way of connecting to a MySQL Database which is localhost.

can anyway give me any ideas of how to do this.

thanks in advance

Andy
Comment
Watch Question

here is the conncetion string for MySQL:

"Provider=MySQLProv;Data Source=mydb;User Id=UserName;Password=asdasd;"

you can alose checkout out the MySQL Connection strings as

http://www.connectionstrings.com/

AW

Author

Commented:
Where in that string Can I supply the server as locahost?

Also Can you show me this integrated with the connectionStrings Tab in the config file. as i am a bit rusty of how to write them

thanks very much

Andy
Have a look at this example: http://www.csharphelp.com/archives2/archive288.html

That includes a example project on how to do it with Oledb.

Author

Commented:
I now get this error

Compiler Error Message: CS0246: The type or namespace name 'MySql' could not be found (are you missing a using directive or an assembly reference?)

Source Error:

 

Line 15:     protected void Page_Load(object sender, EventArgs e)
Line 16:     {
Line 17:         MySql.Data.MySqlClient.MySqlConnection conn;
Line 18:         string myConnectionString;
Line 19:
 
You need to add the library MySql to your project. Right Click on your project name. Click Add Reference and add the approriate dll.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
I have done that. in visual Studio. then I ssave it close it down and copy all the files to the server. It then again gives me the error message. Why will it not find it on the server when the bin directory is write there
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.