you need a mysql connector
http://dev.mysql.com/downloads/connector/net/1.0.html[
^]
donload from here then add reference in project
add this line in Proj
using MySql.Data.MySqlClient;
private void Form1_Load(object sender, EventArgs e)
{
//Set up connection string
string connString = @" server = localhost;
database = sujeetdb;
user id = root;
password =12345; ";
//Set up query string
string sql = @" select * from login ";
MySqlConnection conn=null ;
try
{
conn = new MySqlConnection(connString);
conn.Open();
MySqlCommand cmd = new MySqlCommand(sql, conn);
MySqlDataAdapter adap = new MySqlDataAdapter(cmd);
DataSet ds = new DataSet();
adap.Fill(ds);
dataGridView1.DataSource=ds.Tables[0];
}
catch (Exception ex)
{
Console.WriteLine("Error " + ex);
}
finally
{
conn.Close();
}
}