|
-
May 19th, 2011, 06:19 AM
#1
Thread Starter
New Member
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.
-
May 19th, 2011, 06:36 AM
#2
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".
-
May 19th, 2011, 06:40 AM
#3
Thread Starter
New Member
Re: Working with Dataset and Null Values
 Originally Posted by iPrank
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.
-
May 19th, 2011, 06:46 AM
#4
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)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|