andreasen
May 10th, 2004, 02:35 PM
I am trying to code some Access DB queries in C# and cannot get the DateTime cells to read properly. Here's a snippet of something I have that is not working.
INSERT INTO TestDB ([ID][Time]) VALUES (1, #5/10/2004 1:12:09 PM#)
The Time column is a DateTime:General Date format cell. The actual value for the time is generated using the System.DateTime class - i.e.
StringBuilder cmdString = new StringBuilder();
cmdString.Append("INSERT INTO TestDB ([ID],[Time]) VALUES (1, #");
cmdString.Append(System.DateTime.Now);
cmdString.Append("#)");
Of course this is failing, and if I remove the references to the date information, it works as expected. The same (similar) thing occurs when using references to DateColumn cell contents, i.e.
I also get similar (reader is null) failures when referencing the column contents
ie.
SELECT [ID] FROM TestDB WHERE ([Time]=#5/10/2004 1:12:09 PM#)
Can someone help me learn how to use DateTime cells with C#?
Thanks.
-b
INSERT INTO TestDB ([ID][Time]) VALUES (1, #5/10/2004 1:12:09 PM#)
The Time column is a DateTime:General Date format cell. The actual value for the time is generated using the System.DateTime class - i.e.
StringBuilder cmdString = new StringBuilder();
cmdString.Append("INSERT INTO TestDB ([ID],[Time]) VALUES (1, #");
cmdString.Append(System.DateTime.Now);
cmdString.Append("#)");
Of course this is failing, and if I remove the references to the date information, it works as expected. The same (similar) thing occurs when using references to DateColumn cell contents, i.e.
I also get similar (reader is null) failures when referencing the column contents
ie.
SELECT [ID] FROM TestDB WHERE ([Time]=#5/10/2004 1:12:09 PM#)
Can someone help me learn how to use DateTime cells with C#?
Thanks.
-b