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

标签 sql razor webmatrix

尝试将数据插入到我的 SQl 数据库时,出现以下错误 System.Data.SqlServerCe.SqlCeException:解析查询时出错。 [ token 行号 = 1, token 行偏移量 = 52, token 错误 = ) ] 我输入数据的代码行如下:

@{
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 行。

最佳答案

尾随逗号是我的猜测。将sql插入语句更改为:

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

关于sql - 解析查询时出错。 [ token 行号 = 1, token 行偏移量 = 52, token 错误 = ) ],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9985746/

相关文章:

asp.net-core - 不同的基本路径取决于开发/生产环境

asp.net - 在 ASP.NET 网页/WebMatrix 项目中启用输出缓存

mysql - 从表中的同一列中获取多个值

c# - 为传递给局部 View 的模型设置默认值

asp.net - 使用带有 GET 方法和操作参数的 MVC Html.BeginForm

c# - ASP.net Razor - 使用 GMail SMTP 从网站发送电子邮件

c# - WebMatrix session 变量不起作用

sql - 会计部第二高薪资如何拿?

c# - 如何在ado net中使用UPDATE

mysql - SQL 中可以有 "null rows"吗?