Best way to check if column returns a null value (from database to .net application)

前端 未结 6 1885
别跟我提以往
别跟我提以往 2020-12-09 15:45

I have a table with a DateTime column the column can have NULL values

Now I connect to the database using an ODBC connection and get the value into a DataTable in .n

6条回答
  •  执念已碎
    2020-12-09 15:56

    Use DBNull.Value.Equals on the object without converting it to a string.

    Here's an example:

       if (! DBNull.Value.Equals(row[fieldName])) 
       {
          //not null
       }
       else
       {
          //null
       }
    

提交回复
热议问题