I got an error, "Syntax error (missing operator) in query expression ''Blanco, Familyname='Grace'."
in my code, near ExcecuteQuery();
I am performing Update from MSAccess, I can retreive data but when I used to click my update button, I got error.
anyone can help me?
Heres my code
`private void button1_Click(object sender, EventArgs e)
Records f1 = new Records();
string SQLUpdateString;
if (BlockNo == "")
{
SQLUpdateString = "UPDATE Personaldata SET BlockNo ='" + BlockNo.Replace("'", "''") + "', 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.Replace("'", "''") + "', 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();//error here
MessageBox.Show("Update successful!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
Close();
}`
what should I do? pls help me