Quote:
quote:Originally posted by vickyj
Now what is the solution for this problem.
|
If you cannot work out the "solution" on your own with the information that was given, you are going to have a
lot of trouble down the line, since it seems there are many fundamental things about programming in
VB.NET you don't appear to understand. You really shouldn't have to be given the answer.
But, I don't want to be accused of being unhelpful, so:
Code:
dim chk as object
...
chk = cmdmax.executescalar
If chk = system.dbnull.value Then
maxid = 0
Else
maxid = CInt(chk)
EndIf
...
The 'typecast' function in
VB.NET is either CTYPE or DIRECTCAST depending on the situation. DIRECTCAST doesn't really apply here, so the type conversion function CTYPE could be used in place of the CInt, (they're equivalent) as:
Code:
maxid = CType(chk, Integer)
Alternatively, you could also use the IsDBNull function to test for the NULL value, as:
Code:
If IsDBNull(chk) Then
maxid = 0
Else
maxid = CInt(chk)
EndIf
Good luck. You are probably going to need it.
Jeff Mason
Custom Apps, Inc.
www.custom-apps.com