admin

解析查询时出错。[令牌行号= 1,令牌行偏移量= 52,令牌错误=)]

sql

尝试将数据插入我的SQl数据库时,出现以下错误,System.Data.SqlServerCe.SqlCeException: There was an error parsing the query. [ Token line number = 1,Token line offset = 52,Token in error = ) ]我输入数据的代码行如下:

@{
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);
    }
}

我正在尝试将文件上传到我的服务器,并将文件名添加到我的数据库。该错误显然与第15行有关。


阅读 97

收藏
2021-06-07

共1个答案

admin

我以逗号结尾。将sql插入语句更改为此:

var SQLINSERT = "INSERT INTO Games (Name, file_path) " + "VALUES (@0, @1)";
2021-06-07