解析查询时出错。 [令牌行号=1,令牌行偏移量=15,错误令牌=用户]
Error parsing the query. [ Token line number = 1,Token line offset = 15,Token in error = User ]
我正在处理我的第一个本地 SQL 服务器 CE 数据库 (.sdf
) 项目。我在数据库中创建了一个 table 并添加了一些列。
现在我想创建我的第一个语句,但出现以下错误:
error parsing the query. [ Token line number = 1,Token line offset =
15,Token in error = User ]
Error on that line: `SqlCeDataReader sqlDataReader =
cmd.ExecuteReader();
代码:
using (SqlCeConnection conn = new SqlCeConnection())
{
conn.ConnectionString = ConfigurationManager.ConnectionStrings["StarterSite"].ConnectionString;
conn.Open();
using (SqlCeCommand cmd = new SqlCeCommand("SELECT * FROM User WHERE LOWER(bname) = LOWER(@0)", conn))
{
cmd.Parameters.AddWithValue("0", bname);
SqlCeDataReader sqlDataReader = cmd.ExecuteReader();
string retbname = sqlDataReader["password"].ToString();
sqlDataReader.Close();
}
}
使用
"SELECT * FROM [user] WHERE LOWER(bname) = LOWER(@0)"
而不是:
"SELECT * FROM User WHERE LOWER(bname) = LOWER(@0)"
user 是 sql 服务器中的关键字!
我正在处理我的第一个本地 SQL 服务器 CE 数据库 (.sdf
) 项目。我在数据库中创建了一个 table 并添加了一些列。
现在我想创建我的第一个语句,但出现以下错误:
error parsing the query. [ Token line number = 1,Token line offset = 15,Token in error = User ]
Error on that line: `SqlCeDataReader sqlDataReader = cmd.ExecuteReader();
代码:
using (SqlCeConnection conn = new SqlCeConnection())
{
conn.ConnectionString = ConfigurationManager.ConnectionStrings["StarterSite"].ConnectionString;
conn.Open();
using (SqlCeCommand cmd = new SqlCeCommand("SELECT * FROM User WHERE LOWER(bname) = LOWER(@0)", conn))
{
cmd.Parameters.AddWithValue("0", bname);
SqlCeDataReader sqlDataReader = cmd.ExecuteReader();
string retbname = sqlDataReader["password"].ToString();
sqlDataReader.Close();
}
}
使用
"SELECT * FROM [user] WHERE LOWER(bname) = LOWER(@0)"
而不是:
"SELECT * FROM User WHERE LOWER(bname) = LOWER(@0)"
user 是 sql 服务器中的关键字!