locked
AccessDataSource Update Event Error RRS feed

  • Question

  • User-72198832 posted

    I have my Access database bound to a Gridview and an able to Edit and Update the Grid as long as all columns are set to ReadOnly=False. 

    If I make one or more columns ReadOnly=True I get the following error on updating:

     

    You tried to assign the Null value to a variable that is not a Variant data type

    How do I get past that problem?

     

    Lee

    Saturday, November 6, 2010 10:32 AM

Answers

  • User1716267170 posted

    If a property is marked as ReadOnly, its value will not be passed in the update method (except the primary key) and it'll cause the null value error. In the update method, if you still want to use the value, you may re-assign it in the updating event. Thanks.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, November 10, 2010 3:46 AM

All replies

  • User-1659704165 posted

    Hi,

    http://blogs.msdn.com/b/jongallant/archive/2009/05/02/solution-to-the-you-tried-to-assign-the-null-value-to-a-variable-that-is-not-a-variant-data-type-exception.aspx

    http://forums.asp.net/p/1116521/1732954.aspx

    have u seen the above link


    Sunday, November 7, 2010 2:54 AM
  • User-72198832 posted

    The referenced items do not apply here.

    Problem occurs on UPDATE when one or more of the edit fields are marked ReadOnly.

    If ReadOnly is False all works OK.


    Any other Ideas?


    Lee


    Sunday, November 7, 2010 10:48 AM
  • User1716267170 posted

    If a property is marked as ReadOnly, its value will not be passed in the update method (except the primary key) and it'll cause the null value error. In the update method, if you still want to use the value, you may re-assign it in the updating event. Thanks.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, November 10, 2010 3:46 AM