How to handle null value in sql statement?

B

Butt Chin Chuan

I use a select statement to try to get the max ID for my
table, "Select max (ID) as CurrentMaxID from Table1", and
since the table is blank (newly created), I will get a
return row with Null value. I couldn't execute the
following statement, "objSqlDataAdapter.Fill
(objDataset, "Table1")". In eVB, I can use this statement
to check the Null value, "If IsNull(rs.Fields
("CurrentMaxID").Value) Then ... End If ". Can anyone
please inform me the equalvalent of the above statement to
check the Null value in VB.net? Thank you.
 
D

Dave Corun

Sounds like you might want to use this function

Microsoft.VisualBasic.Information.IsDbNull(ByVal Expression as Object) as
boolean

I use it in my app to test fields in a DataRow to see if they're Null.

// Dave



I use a select statement to try to get the max ID for my
table, "Select max (ID) as CurrentMaxID from Table1", and
since the table is blank (newly created), I will get a
return row with Null value. I couldn't execute the
following statement, "objSqlDataAdapter.Fill
(objDataset, "Table1")". In eVB, I can use this statement
to check the Null value, "If IsNull(rs.Fields
("CurrentMaxID").Value) Then ... End If ". Can anyone
please inform me the equalvalent of the above statement to
check the Null value in VB.net? Thank you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top