.Net and MySQL: Example of using MySQL and .Net: A simple example of useing Connector/Net 5.2 to connect with MySQL from .Net

Follow this process:

  1. Download Connector/Net 5.2.
  2. Unzip the binaries. You will find 3-4 dlls along with other files.
  3. Add reference to mysql.data.dll, in your project.
  4. You can connect to MySQL throw code, as described below:

String conString = “server=server_name; user id=user_name;

password=password; database=db_name; pooling=false;”;

String queryString = “select * from employee;”;

using (MySqlConnection mySqlConnection = new MySqlConnection(conString))

{

using (MySqlDataAdapter adapter = new MySqlDataAdapter(queryString, mySqlConnection))

{

DataTable dt = new DataTable();

adapter.Fill(dt);

dataGridView1.DataSource = dt;

}

}

Published in: on July 27, 2009 at 8:39 pm  Leave a Comment  
Tags: , , , , , ,

C# .Net and MySQL: how to connect MySQL from .Net ?

I was wondering how to connect MySQL with .Net then i got following solutions in net:

http://www.15seconds.com/issue/050407.htm

http://dev.mysql.com/tech-resources/articles/dotnet/index.html#ADO.NET

There might be several other articles describing several other ways to connect with MySQL from .Net but I found Connector/Net 5.2 from MySQL good.