473,385 Members | 1,934 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,385 software developers and data experts.

Problem with null value for datetime field in a tableadapter

I am going through a dataset with dates and I would like to compare
date fields. Example on next line.

If CoreEmployeeBirthDate <Me.DSeePersonal.eePersonal(0).BirthDate
Then

I hit a date that is null and I get the following exception:

Throw New System.Data.StrongTypingException("The value for column
'BirthDate' in table 'eePersonal' is DBNull.", e)

Is there anyway around this exception check?

May 9 '07 #1
3 7990
On May 9, 1:16 pm, k.knud...@fcl.ca wrote:
I am going through a dataset with dates and I would like to compare
date fields. Example on next line.

If CoreEmployeeBirthDate <Me.DSeePersonal.eePersonal(0).BirthDate
Then

I hit a date that is null and I get the following exception:

Throw New System.Data.StrongTypingException("The value for column
'BirthDate' in table 'eePersonal' is DBNull.", e)

Is there anyway around this exception check?
You could always check the value for dbnull before comparing it.

Something like:

If Me.DSeePersonal.eePersonal(0).BirthDate <DbNull AndAlso
CoreEmployeeBirthDate <Me.DSeePersonal.eePersonal(0).BirthDate Then
....
End If

Thanks,

Seth Rowe

May 9 '07 #2
On May 9, 12:30 pm, rowe_newsgroups <rowe_em...@yahoo.comwrote:
On May 9, 1:16 pm, k.knud...@fcl.ca wrote:
I am going through a dataset with dates and I would like to compare
date fields. Example on next line.
If CoreEmployeeBirthDate <Me.DSeePersonal.eePersonal(0).BirthDate
Then
I hit a date that is null and I get the following exception:
Throw New System.Data.StrongTypingException("The value for column
'BirthDate' in table 'eePersonal' is DBNull.", e)
Is there anyway around this exception check?

You could always check the value for dbnull before comparing it.

Something like:

If Me.DSeePersonal.eePersonal(0).BirthDate <DbNull AndAlso
CoreEmployeeBirthDate <Me.DSeePersonal.eePersonal(0).BirthDate Then
...
End If

Thanks,

Seth Rowe
Thanks Seth, but I get the following error when trying to check for
dbnull:

Overload resolution failed because no accessible '=' can be called
with these arguments:
'Public Shared Operator =(d1 As Date, d2 As Date) As Boolean': Value
of type 'System.DBNull' cannot be converted to 'Date'.
May 9 '07 #3
On May 9, 2:04 pm, k.knud...@fcl.ca wrote:
On May 9, 12:30 pm, rowe_newsgroups <rowe_em...@yahoo.comwrote:


On May 9, 1:16 pm, k.knud...@fcl.ca wrote:
I am going through a dataset with dates and I would like to compare
date fields. Example on next line.
If CoreEmployeeBirthDate <Me.DSeePersonal.eePersonal(0).BirthDate
Then
I hit a date that is null and I get the following exception:
Throw New System.Data.StrongTypingException("The value for column
'BirthDate' in table 'eePersonal' is DBNull.", e)
Is there anyway around this exception check?
You could always check the value for dbnull before comparing it.
Something like:
If Me.DSeePersonal.eePersonal(0).BirthDate <DbNull AndAlso
CoreEmployeeBirthDate <Me.DSeePersonal.eePersonal(0).BirthDate Then
...
End If
Thanks,
Seth Rowe

Thanks Seth, but I get the following error when trying to check for
dbnull:

Overload resolution failed because no accessible '=' can be called
with these arguments:
'Public Shared Operator =(d1 As Date, d2 As Date) As Boolean': Value
of type 'System.DBNull' cannot be converted to 'Date'.- Hide quoted text -

- Show quoted text -
I found the answer. I need the following line:

If Me.DSeePersonal.eePersonal(0).IsBirthDateNull Then

May 9 '07 #4

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

Similar topics

3
by: KathyB | last post by:
I'm trying to concatenate fields in SQL stored proc for use in text field in asp.net dropdownlist. I'm running into a problem when I try to use a DateTime field, but can't find the answer (so far)...
0
by: john | last post by:
Hi,All Gurus: It is kind of complicated, please bear with me and let me know if you have any questions. Thanks a lot in advance. John I have a csharp method, using emit to dynamically generate...
6
by: FatboyCanteen | last post by:
When I using dataset to append a null value to the datetime field. It throw a error -> can not convert db.null to system.date Can there is any standard to pass a Null value to the DateTime...
5
by: Kevin Yu | last post by:
hi all since the DateTime can't be assign null, the min value is set to 1901 or something, if in a application design, the date field can be null, so in between the UI and the DB, the business...
7
by: Dabbler | last post by:
I'm using an ObjectDataSource with a stored procedure and am getting the following error when trying to update (ExecuteNonQuery): System.Data.SqlClient.SqlException: Procedure or Function...
5
by: AAJ | last post by:
Hi Does anyone know of any good publically available set of standards for managing dates when dealing with a database server (in my case SQL Server 2000 and c# VS2005). At the moment, if I...
4
by: =?Utf-8?B?QmFidU1hbg==?= | last post by:
Hi, I have a GridView and a SqlDataSource controls on a page. The SqlDataSource object uses stored procedures to do the CRUD operations. The DataSource has three columns one of which -...
8
by: Martin Z | last post by:
INSERT INTO dbo.Transmission (TransmissionDate, TransmissionDirection, Filename, TransmittedData) VALUES (@TransmissionDate,@TransmissionDirection,@Filename,@TransmittedData); SELECT @retVal =...
1
by: Brad Pears | last post by:
I am using vb.net 2005 and SQL server 2000. In my table I have a date field of type "smalldatetime". In my vb application, the user may or may not enter a date value into the appropriate text box....
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.