Update record and change value from integer to dbnull

i am updating a record and changing a value from 5 and would like to change it to be blank (dbnull).  When i attempt to do this now it spits back an error message. 


What is the proper proceedure for entering dbnull into a field.



ps. i am using vs 2k5 and an access 2k3 db.


Answer this question

Update record and change value from integer to dbnull

  • Zeeshan Anwer Khatri

    I think what ivolved mean is you need to check the access database and make sure that the column allow a null value to be inserted. Simply open up the mdb file using access and look at the table design.

    hope it helps,

    Ivan Wong


  • theresa valentine

    i understand that, so lets say it does allow it, what is the proper proceedure for setting a field to null

  • Qaiser Mehmood Mughal

     rbreidenstein wrote:
    i understand that, so lets say it does allow it, what is the proper proceedure for setting a field to null

    Fortunately with .Net 2.0, we have native support of nullable value types. Before, you had to hand code the nullable type wrapper and if you were working in VB.net most of the tricks that work in C# to implement nullables (i.e. operator overloading) didn't work.

    So with this little introduction out of the way I'll answer your question. The way to pass nulls to the database is to use a nullable type. Here is an article on Nullables in VB.Net. And here is one on Nullables in C#.

    Hope this helps get you started down the right path.

    Michael



  • Christopher11

    I don't have the code in front of me sorry,  but can you confirm what i should set the field = to

    example

    newRow("Col1") = dbnull.value

  • InfoDOG

     rbreidenstein wrote:
    i am updating a record and changing a value from 5 and would like to change it to be blank (dbnull).  When i attempt to do this now it spits back an error message. 


    What is the proper proceedure for entering dbnull into a field.
    ps. i am using vs 2k5 and an access 2k3 db.

    What is the error message If the field has a not-null constraint you can't set it to be null. Apologies if I'm stating the obvious to you, just want to make sure we're covering all the bases.



  • Update record and change value from integer to dbnull