how to retrieve data from table to a datagridview in mysql [Resolved]

Posted by Jerome under ASP.NET on 3/21/2012 | Points: 10 | Views : 3533 | Status : [Member] | Replies : 4
select from mysql table and display it into the datagridview...pls show me how...thanks!




Responses

Posted by: Rajni.Shekhar on: 3/21/2012 [Member] Bronze | Points: 50

Up
0
Down

Resolved
Use System.Data; and System.Data.SqlClient

//create connection as per your database
MySqlConnection con = new MySqlConnection(@"server=localhost;User Id=userID;database=db"); //replace userID as u are using and db by your database name
con.Open();

MySqlDataAdapter adp = new MySqlDataAdapter("Select * from table1;" ,con);

DataSet ds = new DataSet();
adp.Fill(ds);
dataGridView1.DataSource = ds;
dataGridView1.DataBind();





Thanks,
Rajni Shekhar

Jerome, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sksamantaray on: 3/21/2012 [Member] Silver | Points: 25
Posted by: Jerome on: 3/21/2012 [Member] Starter | Points: 25

Up
0
Down
thanks for responce,ill try it..


Jerome, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rajni.Shekhar on: 3/21/2012 [Member] Bronze | Points: 25

Up
0
Down
hi Jerome,

please mark as answer if you find any reply as your answer.

Thanks,
Rajni Shekhar

Jerome, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response