private void button2_Click(object sender, EventArgs e)
{
GetMessage();
}
private DataTable GetMessage() {
string P_Str_ConnectionStr = string.Format("server={0};user id = {1};port = {2};database=my_db2;pooling = false;", "localhost", "root", 3306);
string P_Str_SqlStr = string.Format("SELECT id,name FROM student");
MySqlDataAdapter adapter = new MySqlDataAdapter(P_Str_SqlStr,P_Str_ConnectionStr);
DataTable P_dt = new DataTable();
adapter.Fill(P_dt);
this.dataGridView1.DataSource = P_dt;
return P_dt;
}