7 Comments

  • Another solution, if you have a huge quantity of fields, is to do a concatenation with an empty string.





    It works for me well in VB.





    ( I know it's not the 'cleanest' way :-))





    myPhone = myDatareader("FieldPhone") + ""

  • sometimes i use "if typeof myDBNullObject is dbnull then"

  • With typed DataSets you can just use Is[Field]Null. e.g.: If you have a column named PersonId, you can use myRow.IsPersonIdNull.



    Remember, this only works in typed DataSets.

  • Hi there I have this line of code but it seems that it's ignoring the else statement. Any help will be greatly appreciated. Thanks.



    If empRecord.IsNull("Email") Then

    empRecord("Email") = "Not Available"

    Else

    empRecord("Email") = dataReader.GetString(dataReader.GetOrdinal("Email"))

    End If

  • One clean way to handle NULL values is to not bother checking for them, just convert them on the fly:



    myString = Convert.ToString(myDataField("SomeString"))

    myInteger = Convert.ToInt32(myDataField("SomeInteger"))



    and so on.

  • if (cstr(rs3(1)) is null) then

    a= 0

    Response.Write a

    end if

  • Thanks MarcJ your solution is great!

Comments have been disabled for this content.