oledbDataReader - how to read Date value?

  • Thread starter Thread starter James
  • Start date Start date
J

James

....
rdr = cmd.ExecuteReader()
Do While rdr.Read()
For i = 0 To rdr.FieldCount - 1
If Not rdr.IsDBNull(i) Then
Console.WriteLine(rdr.GetString(i))
End If
Next
Loop

The data rdr is reading consists of text, dates, and
numbers. It is having a casting problem on the date
values. How can I read a date value with an
oledbDataReader?

Thanks
 
Hi James!

...
rdr = cmd.ExecuteReader()
Do While rdr.Read()
For i = 0 To rdr.FieldCount - 1
If Not rdr.IsDBNull(i) Then
Console.WriteLine(rdr.GetString(i))
End If
Next
Loop

The data rdr is reading consists of text, dates, and
numbers. It is having a casting problem on the date
values. How can I read a date value with an
oledbDataReader?

Did you try rdr.GetDateTime() or
DateTime.Parse(rdr.GetString()) ?

Cheers

Arne Janning
 
No. I haven't. Of course, that would be a property that I
missed, rdr.GetDateTime. My head was spinning around too
fast this afternoon. And, no I did not try
DateTime.Parse. But I will try each of this tommorrow.

Thanks for the help.
 
Back
Top