Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try
- {
- string MyConnection2 = "datasource=localhost;port=3307;username=root;password=root";
- //Display query
- string Query = "select * from student.studentinfo;";
- MySqlConnection MyConn2 = new MySqlConnection(MyConnection2);
- MySqlCommand MyCommand2 = new MySqlCommand(Query, MyConn2);
- // MyConn2.Open();
- //For offline connection we weill use MySqlDataAdapter class.
- MySqlDataAdapter MyAdapter = new MySqlDataAdapter();
- MyAdapter.SelectCommand = MyCommand2;
- DataTable dTable = new DataTable();
- MyAdapter.Fill(dTable);
- dataGridView1.DataSource = dTable; // here i have assign dTable object to the dataGridView1 object to display data.
- // MyConn2.Close();
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
Add Comment
Please, Sign In to add comment