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.