Guest User

Untitled

a guest
May 3rd, 2018
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. try
  2. {
  3. string MyConnection2 = "datasource=localhost;port=3307;username=root;password=root";
  4. //Display query
  5. string Query = "select * from student.studentinfo;";
  6. MySqlConnection MyConn2 = new MySqlConnection(MyConnection2);
  7. MySqlCommand MyCommand2 = new MySqlCommand(Query, MyConn2);
  8. // MyConn2.Open();
  9. //For offline connection we weill use MySqlDataAdapter class.
  10. MySqlDataAdapter MyAdapter = new MySqlDataAdapter();
  11. MyAdapter.SelectCommand = MyCommand2;
  12. DataTable dTable = new DataTable();
  13. MyAdapter.Fill(dTable);
  14. dataGridView1.DataSource = dTable; // here i have assign dTable object to the dataGridView1 object to display data.
  15. // MyConn2.Close();
  16. }
  17. catch (Exception ex)
  18. {
  19. MessageBox.Show(ex.Message);
  20. }
Add Comment
Please, Sign In to add comment