Yes, Language
is a Access database engine reserved word. You could find a complete list of MS-Access reserved keywords here. The general rule is to try to avoid using any of these words to name tables/columns. However, if you absolutely need it, you can use the [
and ]
symbol around the column name to escape it.
This error ('Syntax error in INSERT INTO statement') is displayed while my Query is correct
رضا جافری
1,296
Reputation points
First and foremost, I apologize for my grammatical errors; my first language is Persian (Iran).
This error ('Syntax error in INSERT INTO statement') is displayed while my Query is correct but i solved the problem- and i just want to know the cause of this problem?
OleDbCommand OleDbCommand_Insert = new OleDbCommand("Insert Into [BookTable](BookName,Publisher,Category,BookCode,Stock,HistoryTaken,RecipientName,ReturnDate,ReleaseDate,Language,Length,Form,Translator,Narrator,ISBN,Location,BookImage)values('" + BookName_TextBox.Text.Trim() + "','" + Publisher_TextBox.Text.Trim() + "','" + Category_ComboBox.Text.Trim() + "','" + BookCode_TextBox.Text.Trim() + "','" + Stock_ComboBox.Text.Trim() + "','" + HistoryTaken_TextBox.Text.Trim() + "','" + RecipientName_TextBox.Text.Trim() + "','" + ReturnDate_TextBox.Text.Trim() + "','" + ReleaseDate_TextBox.Text.Trim() + "','" + Language_TextBox.Text.Trim() + "','" + Length_TextBox.Text.Trim() + "','" + Form_ComboBox.Text.Trim() + "','" + Translator_TextBox.Text.Trim() + "','" + Narrator_TextBox.Text.Trim() + "','" + ISBN_TextBox.Text.Trim() + "','" + Location_TextBox.Text.Trim() + "',@Image)", OleDbConnect);
I changed the header of the "Language" column in the Access database (also in this Query) then the problem was solved:
OleDbCommand OleDbCommand_Insert = new OleDbCommand("Insert Into [BookTable](BookName,Publisher,Category,BookCode,Stock,HistoryTaken,RecipientName,ReturnDate,ReleaseDate,BookLanguage,Length,Form,Translator,Narrator,ISBN,Location,BookImage)values('" + BookName_TextBox.Text.Trim() + "','" + Publisher_TextBox.Text.Trim() + "','" + Category_ComboBox.Text.Trim() + "','" + BookCode_TextBox.Text.Trim() + "','" + Stock_ComboBox.Text.Trim() + "','" + HistoryTaken_TextBox.Text.Trim() + "','" + RecipientName_TextBox.Text.Trim() + "','" + ReturnDate_TextBox.Text.Trim() + "','" + ReleaseDate_TextBox.Text.Trim() + "','" + Language_TextBox.Text.Trim() + "','" + Length_TextBox.Text.Trim() + "','" + Form_ComboBox.Text.Trim() + "','" + Translator_TextBox.Text.Trim() + "','" + Narrator_TextBox.Text.Trim() + "','" + ISBN_TextBox.Text.Trim() + "','" + Location_TextBox.Text.Trim() + "',@Image)", OleDbConnect);
I think "Language" is the keyword in Access 2007. Is this true?
Thanks
Accepted answer
-
Hui Liu-MSFT 48,601 Reputation points Microsoft Vendor
2021-08-02T08:02:08.587+00:00