TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Oladotun Obileye
NA
98
18.9k
How to stop update database from updating all the records
May 24 2019 7:40 PM
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
//SqlConnection con = new SqlConnection();
//con.ConnectionString = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\odt\Documents\Loanapp.mdf;Integrated Security=True;Connect Timeout=30";
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);
Reply
Answers (
1
)
WPF Datagrid + MVVM + Header Change by ViewModel
How to count times a data exist in a column in c#