Null value table cells with optimized compiler

Discussion in 'Questions (Windows Mobile)' started by glook, Jan 4, 2008.

  1. glook

    glook Member Licensed User

    This is not urgent as I've re-coded to avoid the issue - but perhaps interesting in case of future use.

    How is it possible to trap Null values in a Table control column, in a program built with the optimized compiler? I always get an "InvalidCastException" when trying to access the cell.

    The table is loaded from an SQL Select. Some columns may often be Null (no value, not ""). The cell is shown by assigning it to a Textbox.Text, expecting it to be blank if Null. Works fine in the IDE and if compiled un-optimized.

    I attempted trapping it first, but always get the error as soon as the cell is referenced. It can be assigned to a variable, but then it has the same issue, as the value cannot be interpreted.

    By changing to use the DataReader GetValue or IsDBNull instead, there is no problem.

    Geoff.
     
Loading...