Why I can't update data in my database MSAccess?
though, it's already working, but no changes.
Pls help me...
Here's my code for Update
I have 10 Fields in my table Personaldata
try
{
Records f1 = new Records();
BlockNo = textBox1.ToString();
LotNo = textBox2.ToString();
Numberofoccupants = textBox3.ToString();
Firstname = textBox4.ToString();
Familyname = textBox5.ToString();
Dateofbirth = textBox6.ToString();
Age = textBox7.ToString();
Bloodtype = textBox8.ToString();
Placeofbirth = textBox9.ToString();
Religion = textBox10.ToString();
string SQLUpdateString;
if (BlockNo == "")
{
SQLUpdateString = "UPDATE Personaldata SET BlockNo ='" + BlockNo+ "', LotNo='" + LotNo + "', Numberofoccupants='" + Numberofoccupants + "', Firstname='" + Firstname + "', Familyname='" + Familyname + "', Dateofbirth='" + Dateofbirth + "', Age='" + Age + "', Placeofbirth='" + Placeofbirth + "', Religion='" + Religion + "' WHERE BlockNo='" + BlockNo + "'";
}
else
{
SQLUpdateString = "UPDATE Personaldata SET BlockNo ='" + BlockNo + "', LotNo='" + LotNo + "', Numberofoccupants='" + Numberofoccupants + "', Firstname='" + Firstname + "', Familyname='" + Familyname + "', Dateofbirth='" + Dateofbirth + "', Age='" + Age + "', Placeofbirth='" + Placeofbirth + "', Religion='" + Religion + "' WHERE BlockNo='" + BlockNo + "'";
}
OleDbCommand SQLCommand = new OleDbCommand();
SQLCommand.CommandText = SQLUpdateString;
SQLCommand.Connection = f1.database;
int response = SQLCommand.ExecuteNonQuery();
MessageBox.Show("Update successful!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.Hide();
Records frm = new Records();
frm.Show();
}
catch (Exception)
{
MessageBox.Show("something wrong");
}
Thank you