Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void btnUpdate_Click(object sender, EventArgs e)
- {
- try
- {
- if (txtOgrenciNo.Text.Length != 0 && txtAd.Text.Length != 0 && txtSoyad.Text.Length != 0 && txtEmail.Text.Length != 0 && txtTelefon.Text.Length != 0)
- {
- string query ="UPDATE ogrenci(studentId,name,lname,email,phone) SET (studentId=@studentId,name@name,lname=@lname,email=@email,phone=@phone)";
- string query1 = "UPDATE loginusers(username,upassword) SET (username=@email,upassword=@phone)";
- using (connection = new SqlConnection(connectionString))
- using (SqlCommand command = new SqlCommand(query, connection))
- using (SqlCommand cmd = new SqlCommand(query1, connection))
- {
- connection.Open();
- cmd.Parameters.AddWithValue("@emailVal", txtEmail.Text);
- cmd.Parameters.AddWithValue("@phone", txtPhone.Text);
- command.Parameters.AddWithValue("@studentId", txtStudentId.Text);
- command.Parameters.AddWithValue("@name", txtName.Text);
- command.Parameters.AddWithValue("@lname", txtLname.Text);
- command.Parameters.AddWithValue("@email", txtEmail.Text);
- command.Parameters.AddWithValue("@phone", txtPhone.Text);
- cmd.ExecuteNonQuery();
- command.ExecuteNonQuery();
- populateGrid();
- }
- }
- else
- {
- MessageBox.Show("Student Information can not be blank","Alert",MessageBoxButtons.OK,MessageBoxIcon.Information);
- }
- }
- catch (Exception)
- {
- MessageBox.Show("Please enter different student info", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement