您的位置:程序门 -> .net技术 -> vb.net



从类型“dbnull”到类型“integer”的强制转换无效


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


从类型“dbnull”到类型“integer”的强制转换无效[已结贴,结贴人:wx_zl]
发表于:2007-01-06 14:23:23 楼主
定义了个函数   public   function   runcard_query(byval   strtype   as   string,   byval   strdate   as   string,   byval   strclass   as   string)   as   dataset  
dim   data   as   new   dataset()  
dscommand.selectcommand   =   new   sqlcommand( "select   max(cast(substring(runcard,2,9)   as   integer))   as   num   from   runcard   where   type   =   ' "   +   strtype   +   " '   and   classname   =   ' "   +   strclass   +   " '   and   runcard   like   ' "   +   strdate   +   " '   +   '% ' ",   con)  
'dscommand.selectcommand   =   new   sqlcommand( "select   count(*)   as   num   from   runcard   where   type   =   ' "   +   strtype   +   " '   and   classname   =   ' "   +   strclass   +   " '   and   runcard   like   ' "   +   strdate   +   " '   +   '% ' ",   con)  
dscommand.fill(data)  
runcard_query   =   data  
end   function  
引用   ds   =   mysqldata.runcard_query( "wafer_lot ",   strdate,   "pro ")  
dim   i   as   integer  
dim   j   as   integer  

i   =   ds.tables(0).rows(0)( "num ")  

j   =   i   +   1  
……  
结果运行就说从类型“dbnull”到类型“integer”的强制转换无效,请高手指教,急!!!
发表于:2007-01-06 14:38:251楼 得分:10
select   isnull(max(cast(substring(runcard,2,9)   as   integer)),0)   as   num   from   runcard   where   type   ...
发表于:2007-01-06 19:47:092楼 得分:0
if(isdbnull(ds.tables(0).rows(0)( "num ")),0,ds.tables(0).rows(0)( "num ")   )
发表于:2007-01-06 19:47:243楼 得分:0
j=iif(isdbnull(ds.tables(0).rows(0)( "num ")),0,ds.tables(0).rows(0)( "num ")   )


快速检索

最新资讯
热门点击