![](/img/trans.png)
[英]System.Data.SqlClient.SqlException: Incorrect syntax near ')'
[英]System.Data.SqlClient.SqlException: Incorrect syntax near ';'
我无法弄清楚为什么会出现此错误:
System.Data.SqlClient.SqlException:';' 附近的语法不正确
在ExecuteReader
命令上。 这是command.CommandText
语句:
comm.CommandText = "SELECT AcctNumb,TranCode,Code FROM dbo.tablbfee WHERE Code = @cd";
@cd
定义为:
var feeb1 = prmt.Controls.Find("Bt3", true)[0];
comm.Parameters.AddWithValue("@cd", feeb1.Text);
当我找到Bt2
时,我使用了完全相同的代码,它工作正常。
有任何想法吗?
我认为代码是 integer 列,您正在尝试将字符串传递给它。 字符串包含;
并且它不能隐式转换为 integer。
comm.Parameters.AddWithValue("@cd", feeb1.Text);
始终尝试传递正确的数据类型,而不是调用 AddwithValue
comm.Parameters.Add("@cd", SqlDbType.Int);
command.Parameters["@ID"].Value = feeb1.Text; // you will get error here
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.