Select distinct values from datatable, exclude nulls RRS feed

  • Question

  • Ok, I'm doing my best to live in harmony with nulls but not having much luck.  I'm trying to get a distinct list of values from my datatable by using

                Dim q = From a In _paycodesDataTable Order By a.BookingTerminal Where Not (a.IsBookingTerminalNull) Select a.BookingTerminal Distinct

    but I keep getting this error

    "Conversion from type 'DBNull' to type 'String' is not valid."

    According to
    i'm doing this correctly, but i'm still getting the error.  What am I doing wrong?
    Friday, December 11, 2009 8:17 PM


  • Found the problem.

    In my datatable, datacolumn there's a property for null value. I noticed it was set to throw exception.  Looks like this was were my problem was.  I changed it to nothing and everything works as it should.
    • Marked as answer by ThundR Friday, December 11, 2009 9:04 PM
    Friday, December 11, 2009 9:04 PM