I have a table named "Members" in my database.
In a form, I have some Labels
, TextBoxes
, a DataGridView
and a few Buttons.
When I click a row in the DataGridView
, the whole data appears in the corresponding TextBox
correctly.
I have added an "Update" button - which, when clicked I want the database table information to update instantly.
I have written the following code on "Update" button click event. But it shows me error continuously. Please help. I badly need the solution.
string Query = "UPDATE Members SET MemberID='" + MemberIDTextBox.Text + "'|| Name='" + NameTextBox.Text + "'|| Gender='" + GenderComboBox.Text + "'|| Address='" + AddressTextBox.Text + "'|| NID='" + NationalIDTextBox.Text + "'|| DOB='" + DOBTimePicker.Text + "'|| BloodGroup='" + BloodGroupTextBox.Text + "'|| Height='" + HeightTextBox.Text + "'|| Weight='" + WeightTextBox.Text + "'|| ChestSize='" + ChestSizeTextBox.Text + "'|| MusclesSize='" + MusclesSizeTextBox.Text + "'|| AbsPack='" + AbsPackTextBox.Text + "'|| Profession='" + ProfessionTextBox.Text + "'|| Contact='" + ContactTextBox.Text + "' WHERE MemberID='" + MemberIDTextBox.Text + "'";
SqlCommand Command = new SqlCommand(Query, Connection);
Command.ExecuteNonQuery();