这是我给出错误的代码,查询返回特定项目的值。
同样在数据库端,即使我设置了条件,如果阅读器有行,那么查询也会返回行,然后只将它分配给一个变量,但它仍然会引发错误,例如。
dqty = sqlreader("qty")
代码:
Private Function checkquantity(ByVal code As String, ByVal quan As Integer) As Boolean
sqlcommand.CommandText = "select sum(qty) as qty from pos_stock_balance where item_code='" & code & "'"
sqlcommand.Connection = AppsCon
sqlreader = sqlcommand.ExecuteReader
If sqlreader.HasRows Then
dqty = sqlreader("qty")
sqlreader.Close()
Else
sqlreader.Close()
End If
If quan > dqty Then
Return False
Else
Return True
End If
End Function