首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

DBNULL报错,怎么处理?

2014-01-28 
DBNULL报错,怎么处理?cmd New OleDb.OleDbCommand(select MAX(流水号) from sell0 where 流水号0, con

DBNULL报错,怎么处理?

cmd = New OleDb.OleDbCommand("select MAX(流水号) from sell0 where 流水号>0", conn)
  Rd = cmd.ExecuteReader()
 
  If Rd.Read Then
  Rd.Close()
  Label8.Text = Convert.ToInt32(cmd.ExecuteScalar()) + 1
  Else
  Label8.Text = 1
  End If
当SELL0表中没记录时,会报DBNULL,我怎么能用IF来实现在DBNULL情况时执行 Label8.Text = 1?

------解决方法--------------------------------------------------------
if datatable.row(i).item(1) is system.dbnull.value then

Label8.Text = 1
end if

        

热点排行