Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net 位置0处没有行_.net_Vb.net_Ado.net_Exception Handling - Fatal编程技术网

.net 位置0处没有行

.net 位置0处没有行,.net,vb.net,ado.net,exception-handling,.net,Vb.net,Ado.net,Exception Handling,可以这样给出m_qty=ds_uqc.table0.Rows04吗?您会收到一个运行时错误,表示表中根本没有行,因为您的查询字符串没有任何匹配行,您可以先检查行数: cmd.CommandText = "select * from product where prod_code='" & Trim(txtprod_code.Text) & "' and branch='" & w_location & "' and avail_stock <>" &a

可以这样给出m_qty=ds_uqc.table0.Rows04吗?

您会收到一个运行时错误,表示表中根本没有行,因为您的查询字符串没有任何匹配行,您可以先检查行数:

cmd.CommandText = "select * from product where prod_code='" & Trim(txtprod_code.Text) & "' and branch='" & w_location & "' and avail_stock <>" & (0) & ""
cmd.CommandType = CommandType.Text
con.Open()
da_uqc.SelectCommand = cmd
cmd.Connection = con
da_uqc.Fill(ds_uqc)
m_qty = ds_uqc.Tables(0).Rows(0)(4) 'error 
da_uqc.Dispose()
ds_uqc.Dispose()
cmd.Dispose()

备注:VB.Net中的注释以“而不是C.Net注释开始,它告诉您没有加载任何行,可能是因为没有匹配的产品等。这可能是区分大小写的问题,也可能确实没有此类产品


对于信息,使用输入串联是不好的。您应该始终选择参数化命令,这既可以避免在名称中获取引号时出现数据错误,更重要的是可以避免SQL注入。

vb不是基于1的语言吗?我已经好几年没用了,所以我记不清了。@vignesh:确保你的任务回来result@jcomeau_ictx:在vb中,数组是基于1的,但在vb.net中是基于0的:@Devjosh感谢您的澄清!m_qty听说我从数据库中获取数量,并将该值赋给该变量
If ds_uqc.Tables(0).Rows.Count > 0 then
    m_qty = ds_uqc.Tables(0).Rows(0)(4)
End If