解析查询时出错.[令牌行号= 1,令牌行偏移= 52,令牌错误= )] [英] There was an error parsing the query. [ Token line number = 1,Token line offset = 52,Token in error = ) ]

查看:51
本文介绍了解析查询时出错.[令牌行号= 1,令牌行偏移= 52,令牌错误= )]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

我正在尝试将文件上传到我的服务器并将文件名添加到我的数据库中.错误显然是第 15 行.

I am trying to upload a file to my server and add the filename to my database. The error is apparently with line 15.

推荐答案

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

Trailing comma is my guess. change sql insert statement to this:

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

这篇关于解析查询时出错.[令牌行号= 1,令牌行偏移= 52,令牌错误= )]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆