473,406 Members | 2,336 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,406 software developers and data experts.

oledbDataReader - how to read Date value?

....
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
Nov 21 '05 #1
2 4354
Hi James!

"James" schrieb
...
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
Nov 21 '05 #2
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.

-----Original Message-----
Hi James!

"James" schrieb
...
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
.

Nov 21 '05 #3

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

Similar topics

3
by: Buddy | last post by:
Hello, How do I get the number of row retrieved on a SELECT query when using OleDbDataReader? I am using Framework 1.0.
10
by: Dion Heskett | last post by:
I wish to supply the formating as a parameter, I have tried OleDbDataReader but get a null ref. just can't seem to get this to work. I think this has something to do with ExecuteReader. also...
0
by: SRLoka | last post by:
I am using OleDBDataReader with Sybase Anywhere 8 like SQL = "select disclaimer, about from company"; _cmd = new OleDbCommand(SQL,_cn); _dr =...
1
by: Claudia Fong | last post by:
Hi, I'm using the oleDbDataReader HasRows properties to detect wheter my table contains a record with the parameter below: oleDbConnection1.Close(); objreturnst.Parameters.Value =...
0
by: Steve1 via DotNetMonster.com | last post by:
Hi all, I''ve created an OleDbDataReader that will contain the number of records that the used SQL query will return. I'm then using a while loop to loop while the OleDBDataReader object has...
0
by: AbdSol | last post by:
In this code the if statement doesn't work, the value seem to be same when checked in debug in Visual C++ .Net 2003 and .Net 2005 beta1 i can't compile when OleDbConnection is included. Do I...
1
by: Rob Richardson | last post by:
Greetings! I have a database created in MS Access that has some fields containing Currency data. Every time I try to use one of the OleDbDataReader's GetXXX() methods to read it, I get an...
0
by: hmcclungiii | last post by:
I've tried GetInt16, GetInt32, GetInt64, nothing works. I've even tried to retrieve the value as a string and use cInt and Val to convert it back. No matter what I do, it just doesn't want to get...
2
by: Peter | last post by:
Hi, everybody, The codes below run under VS2003 for a long time. I want to upgrade it to VS2005. VS2005 gives me some varning messages such as "Varibles shouldn't be used before being assigned". ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.