View Single Post
  #5 (permalink)  
Old April 8th, 2004, 04:16 PM
gylim78 gylim78 is offline
Registered User
Join Date: Apr 2004
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts

My original code was like this ...

   dim tmp_inv_no2 as integer
   ds = SelectRows(ds,inv_conn_str,mysql,"inv")
   tmp_inv_no2 = ds.tables("inv").compute("MAX(inv_no)","")
   tmp_inv_no2 += 1

But I would get an error saying ...
"System.InvalidCastException: Cast from type 'DBNull' to type 'Integer' is not valid."

In order to find out what was being passed back by ds.tables("inv").compute("MAX(inv_no)",""), I converted the output to a string so that I may view the value. I found that the value returned was indeed the maximum value of inv_no and not a NULL value.

My problem now is that VB.NET is treating the value of ds.tables("inv").compute("MAX(inv_no)","") of a type DBNull, thus I cannot add 1 to it.

Reply With Quote