Skip to content

How can i connect my app to mysql?

Krishna Kishore

Asked Apr 10, 2006, 12:19 AM EDT8 answers
Share
LinkedInX

Hai friends,

I want to use mySql as my backend?(Iam new to that)
From my C# app how to make the connection?

regards,
Kolluru.

8 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • +1

    Using NameSpace :

    using
    System.Data;
    using System.Data.OleDb;

    Call this function:

               private void connectToMySql()
                {
                 OleDbConnection conn=new OleDbConnection("");
                 conn.ConnectionString="Provider=MySQLProv;Data Source=mysql;";
                 try
                 {
                     conn.Open();
                     if (conn.State==ConnectionState.Open)
                         MessageBox.Show("Connection to MySQL opened through OLE DB Provider");
                     conn.Close();
                 }
                 catch(Exception ex)
                 {
                    MessageBox.Show(ex.Message);
                 }
              }




    +1
  • +1

    Using NameSpace :

    using
    System.Data;
    using System.Data.OleDb;

    Put this code in function:

    OleDbConnection conn=new OleDbConnection("");
                conn.ConnectionString="Provider=MySQLProv;Data Source=mysql;";
                try
                {
                    conn.Open();
                    if (conn.State==ConnectionState.Open)
                   MessageBox.Show("Connection to MySQL opened through OLE DB Provider");
                    conn.Close();
                }
                catch(Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }





    +1
  • +1

    Using NameSpace :

    using
    System.Data;
    using System.Data.OleDb;

    Put this code in function:

    OleDbConnection conn=new OleDbConnection("");
                conn.ConnectionString="Provider=MySQLProv;Data Source=mysql;";
                try
                {
                    conn.Open();
                    if (conn.State==ConnectionState.Open)
                    MessageBox.Show("Connection to MySQL opened through OLE DB Provider");
                    conn.Close();
                }
                catch(Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }





    +1
  • +1
    Thank you very much friends...

    Let me try and come back to u again.....

    regards,
    +1
  • +1

    you need to download a driver for that.
    there are few connectors in the net.
    you can try bytefx or something substantial.

    Happy coding :)

    +1
  • +1

    Greetings everyone,

    I just discovered this forum which seems to be a reliable source of information about C# programming and databases implementation.

    Now, I give a try wondering whether one of you knows how to install ByteFX .NET 0.76 with SharpDevelop 2.0. I firstly downloaded and installed the driver on my machine, but I can't use it...

           "using ByteFX.Data.MySqlClient;"

    An error displays that ByteFX can not be found... I read about somewhat an assembly or something, but I can't be sure. Might someone help me resolve this issue ?

    Thank you in advance.

    WILL.

    +1
  • +1
    Just wanted to point out a handy tool that I've written which you can download from my site (http://www.m-s-d.net) - it's basically a nice wrapper for MySQL commands whereby you can just execute as many commands as you want using a single connection. Don't know how much it helps.... Here's the post about it: http://www.m-s-d.net/2006/04/dataexecutor-class.html DataExecutor class and here is the file: http://www.m-s-d.net/files/DataExecutor-v1-0.zip Zipped file Martin
    +1