Connect to MySQL Database

Posted on 2006-04-01
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

Question by:REA_ANDREW
    LVL 44

    Expert Comment

    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

    LVL 20

    Author Comment

    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

    LVL 14

    Expert Comment

    Have a look at this example:

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

    Author Comment

    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:
    LVL 14

    Accepted Solution

    You need to add the library MySql to your project. Right Click on your project name. Click Add Reference and add the approriate dll.
    LVL 20

    Author Comment

    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

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
    In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    729 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

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now