how to check if a datareader is null or empty

前端 未结 12 1746
谎友^
谎友^ 2020-12-24 01:52

I have a datareader that return a lsit of records from a sql server database. I have a field in the database called "Additional". This field is 50% of the time emp

12条回答
  •  伪装坚强ぢ
    2020-12-24 02:27

    In addition to the suggestions given, you can do this directly from your query like this -

    SELECT ISNULL([Additional], -1) AS [Additional]
    

    This way you can write the condition to check whether the field value is < 0 or >= 0.

提交回复
热议问题