Relative Content

Tag Archive for c#databasedatagridviewoledboledbcommand

command.ExecuteNonQuery System.Data.OleDb.OleDbException: ‘Syntax error in date in query expression ‘{the name of the table} = 21′.’

I am using OleDb to have the user select a cell from a data grid view “anzeigeDataGridView” that can switch between Access data bases, have the user input text into a text box “editTextBox” and then have it both edit the value in the cell in the data grid view and also in the Access data base it is taking the data from when the user clicks the button “editButton”.
These are the objects of the class and 3 methods relevant for my problem, LoadData() is called earlier in the program with correct parameters given to it, that part works.
Editing the shown value in the data grid view also worked, but when I tried making it edit the original data base too using ExecuteNoneQuery() with an UPDATE SQL Query it gave me the error in the title of the question.
“tablename” and “tableid” are correctly written in a different part of the program. I am aware of the fact that it can only edit strings as of now because of the ” in the SQL query, but I’ll cross that bridge when I’ll get there, I just need it to be able to edit strings for now.
The error is on the line “if(command.ExecuteNonQuery() > 0)”
I have scraped the internet for the error and ChatGPT is acting like a silly goofster but I can’t seem to find the exact solution to my problem. Could you beautiful people please help me?