473,386 Members | 1,702 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Testing for null value in a dataset

PJ
I have a dataset with a datatable that has a datacolumn of type Date. I have the following code in my application
If IsDBNull(drEmployee.DateStart) = True Then drEmployee.DateStart = Date.Parse("01-Jan-2000"
When this line runs, I get an error message "Cannot get value because it is DBNull", which of course is what I am trying to test for. The dataset was generated using VS designer from an Access database and I have not altered any settings in the XSD. The column in Access is set to "Required = no". Where am I going wrong?
Jul 21 '05 #1
2 1707
PJ
I should add that I have tried setting msprop:nullValue="_null" in the XSD but then the designer comes up with an error stating "Custom tool error: Failed to generate code. System error."
Jul 21 '05 #2
If drEmployee is strongly typed try this:
If drEmployee.IsDateStartNull() Then drEmployee.DateStart =
Date.Parse("01-Jan-2000")

If it's not try this:
If drEmployee.IsNull("DateStart") Then drEmployee.DateStart =
Date.Parse("01-Jan-2000")

"PJ" <an*******@discussions.microsoft.com> wrote in message
news:48**********************************@microsof t.com...
I have a dataset with a datatable that has a datacolumn of type Date. I have the following code in my application: If IsDBNull(drEmployee.DateStart) = True Then drEmployee.DateStart = Date.Parse("01-Jan-2000") When this line runs, I get an error message "Cannot get value because it

is DBNull", which of course is what I am trying to test for. The dataset
was generated using VS designer from an Access database and I have not
altered any settings in the XSD. The column in Access is set to "Required =
no". Where am I going wrong?
Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Shabam | last post by:
A web application of mine developed using C# + MS SQL runs fine normally. However when I stress test it with a load testing software (using about 60 simultaneous users) some instances start...
2
by: WhiskyRomeo | last post by:
I have a bound textbox (bindings are set at design time) to a dataset column. Sometimes the value of this textbox must be set so that the underlying database field gets updated to null when using...
0
by: gilly3 | last post by:
Reposting to a more relevant group. I am passing a generic dataset into a new XMLDataDocument and then parsing the XML with XSLT. The idea being that I can parse any dataset with the same xslt,...
2
by: MS Newsgroups | last post by:
Hi, I am trying to build a function that returns a dataset.When populating the dataset, is it possible to test if a value already exists in a column and only add it if it is not already present...
2
by: PJ | last post by:
I have a dataset with a datatable that has a datacolumn of type Date. I have the following code in my application If IsDBNull(drEmployee.DateStart) = True Then drEmployee.DateStart =...
9
by: GotDotNet? | last post by:
I have a dataset and I have to loop through it and some of the values for an insertition into the db. Some of the fields are integers and booleans but contain a NULL in the field. how can I...
13
by: Fred Chateau | last post by:
I can't seem to find a test for DBNulls. Whatever I try doesn't work. for (int x = 0; x < dataSet.Identity.Rows.Count; x++) { DataRow dataRow = dataSet.Tables.NewRow(); if...
7
by: monika varshney | last post by:
I have to read a database using dataset. My database has some null values. My code is working fine when there is a value in the database. But when there is a null value in the database, dataset...
2
by: BobLewiston | last post by:
Some of you may have seen my earlier thread “PasswordHash NULL problem”. I’ve started a new thread because investigation has shown that the problem is actually quite different than I previously...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.