473,473 Members | 1,513 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Checking if Date is Nothing

Hi all,

I'm experiecing a problem with dates being returned from SQL 2000 Database.
I retrieve the last updated field (Date) from a sql 2000 and then compare
the returned date with another record I'm checking against, to see if they
are the same or if the returned value is nothing, checking to see if the
date are the same works if not nothing. I have tried the following:

Dim datDate As Date = Nothing

If dteSQLUpdate = datDate Then

-----

If dteSQLUpdate = nothing

Thanks
Richard
Nov 21 '05 #1
3 6659
RColby,

Try this sample I just made, I hope that you than you see how the dates work
in a datatable in VBNet (and therefore in a database)?

Cor

\\\Needs a new project with a datagrid on the form
Private Sub Form1_Load(ByVal sender As _
Object, ByVal e As System.EventArgs) _
Handles MyBase.Load
'Making of the test datatable
Dim dt As New DataTable("Test")
dt.Columns.Add("Dat", GetType(System.DateTime))
For i As Integer = 0 To 5
Dim dr As DataRow = dt.NewRow
dr(0) = Now.AddDays(i)
dt.Rows.Add(dr)
Next
'Showing handling of the date in a datatable
dt.Rows(0)(0) = DBNull.Value
For Each dr As DataRow In dt.Rows
If dr(0) Is DBNull.Value Then
dr(0) = Now.AddDays(10)
End If
Next
DataGrid1.DataSource = dt
End Sub
///
Nov 21 '05 #2
* "rcolby" <rc*******@hotmailPLEASEREMOVE.com> scripsit:
I'm experiecing a problem with dates being returned from SQL 2000 Database.
I retrieve the last updated field (Date) from a sql 2000 and then compare
the returned date with another record I'm checking against, to see if they
are the same or if the returned value is nothing, checking to see if the
date are the same works if not nothing. I have tried the following:


'Date' is a value type and cannot be 'Nothing'. Take a look at the
'SqlDateTime' data type.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 21 '05 #3
Thanks for the advise, really getting into programming again.

"rcolby" <rc*******@hotmailPLEASEREMOVE.com> wrote in message
news:41*********************@news.zen.co.uk...
Hi all,

I'm experiecing a problem with dates being returned from SQL 2000 Database. I retrieve the last updated field (Date) from a sql 2000 and then compare
the returned date with another record I'm checking against, to see if they
are the same or if the returned value is nothing, checking to see if the
date are the same works if not nothing. I have tried the following:

Dim datDate As Date = Nothing

If dteSQLUpdate = datDate Then

-----

If dteSQLUpdate = nothing

Thanks
Richard

Nov 21 '05 #4

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

Similar topics

8
by: Robert Mark Bram | last post by:
Howdy All! How can you tell the type of an object? I am not talking about using "typeof" .. I am talking about being able to determine if an object is a Date or String .... Thanks for...
3
by: JackO | last post by:
I have a text box on a form “txtExamDate” that I know contains nothing. I am trying to test code that will determine the text box is nothing. I am getting the error because there is no value...
13
by: John A Grandy | last post by:
apparently references of type Date can not assume the value Nothing, because the following code fails: Dim d As Date .......other code...... If d Is Nothing Then End If so then what is...
0
by: gsb58 | last post by:
Hi! I have a little problem with the registry function. The function is supposed to check the registry as the main form is activated. If there is a key it should not write to the registry, as it...
2
by: Oenone | last post by:
In our applications, we use the special value of DateTime.MinValue to represent "null dates" throughout all our code. We recently ran into an issue where we wanted an optional date parameter for a...
4
by: Patient Guy | last post by:
Does anyone have any coding rules they follow when doing argument checking? When arguments fail during check, do you return from the call with an ambiguous return value, or do you throw...
16
by: lawrence k | last post by:
I've made it habit to check all returns in my code, and usually, on most projects, I'll have an error function that reports error messages to some central location. I recently worked on a project...
1
by: BerkshireGuy | last post by:
I have a Access database that should have data for each weekday of the year. There is a field called DateDownloaded, which should have at least one record for each weekday of the current year. ...
27
by: RobG | last post by:
I was investigating a function to determine whether daylight saving was being observed on a particular date (given the platform's regional settings) and came across a suggestion at merlyn.com 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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.