Good day everyone. please i am working on a c# windows form and whenever i click on the update button it updates all the records instead of a particular record i.e all the record will be updated instead of only one record
-
-
- con.Open();
- SqlCommand cmd = con.CreateCommand();
- cmd.CommandType = CommandType.Text;
- cmd.CommandText = "update Registrationform set Employementnumber=@empno,FullName=@fullname,Dateofbirth=@dob,Gender=@gen,Occupation=@occ,Maritalstatus=@ms,Email=@email,Department=@dept,Position=@post,HomeAddress=@haddress,Phonenumber=@pno,Nationality=@nation,Stateoforigin=@soo,image=@img where Id=@id ";
- cmd.Parameters.AddWithValue("@id", ID);
- cmd.Parameters.AddWithValue("@empno", txtempno.Text);
- cmd.Parameters.AddWithValue("@fullname", txtfullname.Text);
- cmd.Parameters.AddWithValue("@dob", dob.Value);
- cmd.Parameters.AddWithValue("@gen", gender);
- cmd.Parameters.AddWithValue("@occ", txtoccupation.Text);
- cmd.Parameters.AddWithValue("@ms", txtmaritalstatus.GetItemText(txtmaritalstatus.SelectedItem));
- cmd.Parameters.AddWithValue("@email", txtemail.Text);
- cmd.Parameters.AddWithValue("@dept", txtdept.Text);
- cmd.Parameters.AddWithValue("@post", txtpost.Text);
- cmd.Parameters.AddWithValue("@haddress", txthaddress.Text);
- cmd.Parameters.AddWithValue("@pno", txtpno.Text);
- cmd.Parameters.AddWithValue("@nation", txtnation.Text);
- cmd.Parameters.AddWithValue("@soo", txtorigin.Text);
- cmd.Parameters.AddWithValue("@img", img);