Advertisement
Guest User

Untitled

a guest
Feb 3rd, 2017
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. private void btnUpdate_Click(object sender, EventArgs e)
  2. {
  3. try
  4. {
  5. if (txtOgrenciNo.Text.Length != 0 && txtAd.Text.Length != 0 && txtSoyad.Text.Length != 0 && txtEmail.Text.Length != 0 && txtTelefon.Text.Length != 0)
  6. {
  7. string query ="UPDATE ogrenci(studentId,name,lname,email,phone) SET (studentId=@studentId,name@name,lname=@lname,email=@email,phone=@phone)";
  8. string query1 = "UPDATE loginusers(username,upassword) SET (username=@email,upassword=@phone)";
  9. using (connection = new SqlConnection(connectionString))
  10. using (SqlCommand command = new SqlCommand(query, connection))
  11. using (SqlCommand cmd = new SqlCommand(query1, connection))
  12. {
  13. connection.Open();
  14. cmd.Parameters.AddWithValue("@emailVal", txtEmail.Text);
  15. cmd.Parameters.AddWithValue("@phone", txtPhone.Text);
  16. command.Parameters.AddWithValue("@studentId", txtStudentId.Text);
  17. command.Parameters.AddWithValue("@name", txtName.Text);
  18. command.Parameters.AddWithValue("@lname", txtLname.Text);
  19. command.Parameters.AddWithValue("@email", txtEmail.Text);
  20. command.Parameters.AddWithValue("@phone", txtPhone.Text);
  21. cmd.ExecuteNonQuery();
  22. command.ExecuteNonQuery();
  23. populateGrid();
  24. }
  25. }
  26. else
  27. {
  28. MessageBox.Show("Student Information can not be blank","Alert",MessageBoxButtons.OK,MessageBoxIcon.Information);
  29. }
  30. }
  31. catch (Exception)
  32. {
  33. MessageBox.Show("Please enter different student info", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Information);
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement