Results 1 to 4 of 4

Thread: Working with Dataset and Null Values

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2011
    Posts
    6

    Working with Dataset and Null Values

    Hi Guys

    Im pulling lots of data from datasets and placing the values into text fields on my vb form. Im getting a lot of errors relating to null values. What i want to know is if there a simple way of setting a value to the null value reference. Im aware i can add if statements as i already have for various sections but dont want to have to add an if statement for each null value pulled out.

    Any help appreicated.

  2. #2
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: Working with Dataset and Null Values

    Welcome to VBForums !

    If you are using strongly typed dataset (xsd), in dataset designer right click the data column, goto properties. In the properties window see the "NullValue" property. Set it the way you like.

    You can set a variable to DBNull by assigning it DBNull.Value.

    Also, please do a google search for "IsDbNull", "Nullable Data Type", "difference between dbnull and nothing".
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  3. #3

    Thread Starter
    New Member
    Join Date
    May 2011
    Posts
    6

    Re: Working with Dataset and Null Values

    Quote Originally Posted by iPrank View Post
    Welcome to VBForums !

    If you are using strongly typed dataset (xsd), in dataset designer right click the data column, goto properties. In the properties window see the "NullValue" property. Set it the way you like.

    You can set a variable to DbNull by alligning it [b]DbNull.Value[b].

    Also, please do a search for "IsDbNull", "Nullable Data Type".
    Hi Mate yes its an xsd dataset, the field in question wont allow me to set is as empty. Ive tried adding the following line of code to check and assign the value but im getting an error message.

    IIf (IsDBNull(Me.DataSet11.Staff.FindByPayref(EmpVar).Forename1, string.Empty, "Test")

    Its stating to many arguement for IsDBNull, ill have a search on the two criteria you just added now.

  4. #4
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: Working with Dataset and Null Values

    If the field is an Identity field or NotNull field, you may have problem. Try setting "AllowDbNull=True" or remove the constraints/relation from the dataset.
    (I'm not 100% sure about this on XSD, but got similar problem in untyped dataset)
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


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