C#分析查询令牌行编号1时出错
C#分析查询令牌行编号1时出错C#分析查询令牌行编号1时出错,c#,sql,sql-server-ce,C#,Sql,Sql Server Ce,C#分析查询令牌行编号1时出错 cmmd.CommandText = "Select total from Dept_Sales where department ='" + department + "'"; var dtotal = cmmd.ExecuteScalar().ToString(); var nntotal = dtotal + price; SqlCeCommand cmmmmd = new SqlCeCommand("update
cmmd.CommandText = "Select total from Dept_Sales where department ='" + department + "'";
var dtotal = cmmd.ExecuteScalar().ToString();
var nntotal = dtotal + price;
SqlCeCommand cmmmmd = new SqlCeCommand("update [Dept_Sales] SET [total]=@val1) where [department]=@val2", conn);
{
cmmmmd.Parameters.AddWithValue("@val1", nntotal);
cmmmmd.Parameters.AddWithValue("@val2", department);
cmmmmd.CommandType = System.Data.CommandType.Text;
cmmmmd.ExecuteNonQuery() }
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
also dtotal =3.51
and price = 3.51
nntotal = 7.02
我想我的查询可能有问题,我已经更改了15次相同的错误,有人能给我一些建议吗?从第4行删除外部)
。所以应该是这样的:
SqlCeCommand cmmmmd =
new SqlCeCommand("update [Dept_Sales] SET [total]=@val1
where [department]=@val2", conn);
从第4行删除extera)
。所以应该是这样的:
SqlCeCommand cmmmmd =
new SqlCeCommand("update [Dept_Sales] SET [total]=@val1
where [department]=@val2", conn);
不匹配的右括号:
[total]=@val1)
^^^
不匹配的右括号:
[total]=@val1)
^^^