Checking if Date is Nothing

  • Thread starter Thread starter rcolby
  • Start date Start date
R

rcolby

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
 
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
///
 
* "rcolby said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top