While trying to insert data to my SQl db i get the following error System.Data.SqlServerCe.SqlCeException: There was an error parsing the query. [ Token line number = 1,Token line offset = 52,Token in error = ) ]
my lines of code to enter the data are the following:
@{
var db= Database.Open("Games");
var sqlQ = "SELECT * FROM Games";
var data = db.Query(sqlQ);
}
@{
if (IsPost) {
var fileData = Request.Files[0];
var fileName = Path.GetFileName(fileData.FileName);
var fileSavePath = Server.MapPath("~/upload/" + fileName);
fileData.SaveAs(fileSavePath);
var GameName=Request["Name"];
var Gamefile = fileName;
var SQLINSERT = "INSERT INTO Games (Name, file_path) " + "VALUES (@0, @1,)";
db.Execute(SQLINSERT, GameName, Gamefile);
}
}
I am trying to upload a file to my server and add the filename to my database. The error is apparently with line 15.
The problem in my case was in the middle of the sentence have the ' character
example (ERROR)
example (CORRECT)
I resolve the problem with a subtract
Trailing comma is my guess. change sql insert statement to this: