This error ('Syntax error in INSERT INTO statement') is displayed while my Query is correct

رضا جافری 1,296 Reputation points
2021-07-30T20:41:38.777+00:00

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);  

119561-before-the-change.gif

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);  

119562-after-the-change.gif
I think "Language" is the keyword in Access 2007. Is this true?
Thanks

XAML
XAML
A language based on Extensible Markup Language (XML) that enables developers to specify a hierarchy of objects with a set of properties and logic.
790 questions
0 comments No comments
{count} votes

Accepted answer
  1. Hui Liu-MSFT 47,341 Reputation points Microsoft Vendor
    2021-08-02T08:02:08.587+00:00

    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.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful