为了账号安全,请及时绑定邮箱和手机立即绑定

如下所示,ExecuteScalar属性尚未初始化该怎么解决?

如下所示,ExecuteScalar属性尚未初始化该怎么解决?

绝地无双 2022-04-20 15:11:39
SqlCommand cmd = new SqlCommand("select (select isnull(sum(totalquantity),0) from c_inv_transaction where item_id =" + str + " and lot_No ='" + text + "' and transactionType = 'IN') - (select isnull(sum(totalquantity),0) from c_inv_transaction where item_id =" + str + " and lot_No ='" + text + "' and transactionType = 'OUT') as aa");this.label4.Text = (string)cmd.ExecuteScalar();
查看完整描述

2 回答

?
HUX布斯

TA贡献1876条经验 获得超6个赞

SqlConnection con=new SqlConnection(连接字符串);
string sql="select (select isnull(sum(totalquantity),0) from c_inv_transaction where item_id =" + str + " and lot_No ='" + text + "' and transactionType = 'IN') - (select isnull(sum(totalquantity),0) from c_inv_transaction where item_id =" + str + " and lot_No ='" + text + "' and transactionType = 'OUT') as aa";
SqlCommand cmd = new SqlCommand(sql,con) //这里的con你没有

查看完整回答
反对 回复 2022-04-24
?
BIG阳

TA贡献1859条经验 获得超6个赞

SqlCommand中没有指定字符串和CONN连接对象

查看完整回答
反对 回复 2022-04-24
  • 2 回答
  • 0 关注
  • 251 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信