Advertisement
Guest User

Untitled

a guest
May 19th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. private void Update_Click(object sender, EventArgs e)
  2. {
  3. try
  4. {
  5. OleDbConnection connection = new OleDbConnection();
  6. connection.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\user\Desktop\Student\Database.accdb;
  7. Persist Security Info=False;";
  8. connection.Open();
  9.  
  10. OleDbCommand command1 = new OleDbCommand();
  11. command1.Connection = connection;
  12. command1.CommandText = "select * from Student where ID=" + Load_txt.Text;
  13. OleDbDataAdapter da = new OleDbDataAdapter(command1);
  14. DataTable dt = new DataTable();
  15. da.Fill(dt);
  16. dataGridView1.DataSource = dt;
  17. command1.ExecuteNonQuery();
  18. connection.Close();
  19.  
  20. }
  21. catch (Exception ex)
  22. {
  23. MessageBox.Show(ex.ToString(), "error");
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement