locked
How to check if a field Date is empty? RRS feed

  • Question

  • User858916221 posted

    Hi all

     

    how can I check if a daet field in a dataset is empty before assiging it to a string variable

     

    Friday, July 6, 2012 10:07 AM

Answers

  • User3866881 posted

    Hi all

    how can I check if a daet field in a dataset is empty before assiging it to a string variable

    Hello:)

    Please just use DbNull to check:

    if(ds.tables[0].rows[0]["columnname"] is DbNull)
    {
      //do what you want ……
    }
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, July 8, 2012 9:16 PM

All replies

  • User269846090 posted

    if(!string.isnullorempty(ds.tables[0].rows[0]["columnname"].tostring()))

    {

    assign the value to variable

    }

    else

    {

    // leave it.

    }

    Friday, July 6, 2012 10:09 AM
  • User3866881 posted

    Hi all

    how can I check if a daet field in a dataset is empty before assiging it to a string variable

    Hello:)

    Please just use DbNull to check:

    if(ds.tables[0].rows[0]["columnname"] is DbNull)
    {
      //do what you want ……
    }
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, July 8, 2012 9:16 PM