加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

.net – 位置0没有行

发布时间:2020-12-17 07:30:25 所属栏目:百科 来源:网络整理
导读:cmd.CommandText = "select * from product where prod_code='" Trim(txtprod_code.Text) "' and branch='" w_location "' and avail_stock " (0) ""cmd.CommandType = CommandType.Textcon.Open()da_uqc.SelectCommand = cmdcmd.Connection = conda_uqc.Fil
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()

是否有可能像这样给出m_qty = ds_uqc.Tables(0).Rows(0)(4)?

解决方法

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

If ds_uqc.Tables(0).Rows.Count > 0 then
    m_qty = ds_uqc.Tables(0).Rows(0)(4)
End If

P.S:在VB.Net中的评论,以’而不是C#.Net一个//开头.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读