Results 1 to 9 of 9

Thread: [2005] assigning "null" to an item in a datarow?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2005
    Posts
    257

    [2005] assigning "null" to an item in a datarow?

    Apparently this isn't how you do it
    VB Code:
    1. NewRow = TheTable.addrow
    2.                     NewRow.Item(2) = DBNull 'this doesn't work
    3. 'and this parser shouldn't have used lastindexof apostrophe :P
    so how do you stick a null value in there?
    Last edited by Desolator144; Oct 18th, 2006 at 02:19 PM.
    I tried to end process on Visual Studio 2005
    but PETA stopped me saying it's smart enough
    to be a living creature

  2. #2
    Frenzied Member
    Join Date
    Mar 2006
    Location
    Pennsylvania
    Posts
    1,069

    Re: [2005] assigning "null" to an item in a datarow?

    did u try just null?

  3. #3
    Smitten by reality Harsh Gupta's Avatar
    Join Date
    Feb 2005
    Posts
    2,938

    Re: [2005] assigning "null" to an item in a datarow?

    Umm, Shouldn't it be Nothing??

  4. #4
    Frenzied Member
    Join Date
    Mar 2006
    Location
    Pennsylvania
    Posts
    1,069

    Re: [2005] assigning "null" to an item in a datarow?

    potatoe patata. point is.. try different stuff

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2005
    Posts
    257

    Re: [2005] assigning "null" to an item in a datarow?

    the thing is, dbnull should have worked. I think if I assign it to nothing it will try to destroy that datarow.item object and I would try different things except I can't test this at all for reasons I won't get into cuz it's a loooong story so i need to make sure it's correct ahead of time
    I tried to end process on Visual Studio 2005
    but PETA stopped me saying it's smart enough
    to be a living creature

  6. #6
    Frenzied Member
    Join Date
    Mar 2006
    Location
    Pennsylvania
    Posts
    1,069

    Re: [2005] assigning "null" to an item in a datarow?

    well that sucks.. u can't like.. copy the file and use that one as a test file?

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2005
    Posts
    257

    Re: [2005] assigning "null" to an item in a datarow?

    does this look right?
    VB Code:
    1. Dim TheNull As DBNull
    2.         For x As Integer = 0 To tblQues.Rows.Count - 1
    3.             tblQues.Rows(x).Item(1) = TheNull
    4.         Next
    cuz it's giving me the "that's a little iffy" squigglies :P

    and I can't test it cuz I can't import a test from csv file into this database because I used my export test to make it and I don't want to double up tests cuz my management studio is broken (or more likely my mdf file) so I can't easily delete a whole new test cuz it spans 4 tables so I need to alter the csv file myself and import it into another copy of this database then toss that one if it works and make another copy of the original so my instructor can test the import without actually adding it to the original database. See told you it was complicated.
    I tried to end process on Visual Studio 2005
    but PETA stopped me saying it's smart enough
    to be a living creature

  8. #8
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: [2005] assigning "null" to an item in a datarow?

    DBNull is a class, so you can't just assign DBNull to a field. DBNull is the type of the object stored in a null field, not the value of the object.
    VB Code:
    1. tblQues.Rows(x).Item(1) = DBNull.Value
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2005
    Posts
    257

    Re: [2005] assigning "null" to an item in a datarow?

    w00t! you're a genius Here I got you one of those new vehicles that runs on corn. It's a slightly older model though...

    I tried to end process on Visual Studio 2005
    but PETA stopped me saying it's smart enough
    to be a living creature

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width