VS.NET and DateTimes? Bug in VS.NET?

  • Thread starter Thread starter Siegfried Heintze
  • Start date Start date
S

Siegfried Heintze

I used Access to define a record with a couple of columns of type TimeStamp.
When using perl, I use the syntax {ts '2004-MAR-15 23:44:22'} to insert a
value using the SQL insert statement. It works great (except for the fact
that I'm using Perl cgi.)

So I now abandon perl in favor of VB.NET on VS.NET and I drag and drop this
table into VS.NET forms designer, create my trusty data adapter, define an
early bound dataset, fill my dataset and bind my datagrid to the dataset and
viola! It works!

Except for one problem: none of the hours, minutes seconds are correct!
Hmmm.... So I tried to fix the problem by changing all the occurances of
DBTime to DBTimeStamp and all the occurances of Date to DateTime. After
fixing a few syntax erros (like changing UpdateTimeCommand to UpdateCommand)
I compile and no syntax errors... ! Great now I run it and single step with
the debugger as I populate my OleDB insert command object with values and
then call ExecuteScalar() and.... it does with an datatype mismatch
exception! Arghh... Foiled again!

I even tried abanding the use of parameterized SQL statements and
concatentated some strings to say
INSERT INTO MYTABLE (DOM) VALUES ({ts '2004-MAR-16 22:44:22'}) and did not
like that either. Why not? It works in Perl!

How can I make VS.NET store hours minutes and seconds along with the date?

Thanks,
Siegfried
 
Siegfried:

Use parameter objects instead and leave the worry behind:
command.CommandText = "INSERT INTO MYTABLE (DOM) VALUES (?)"
cmd.Parameters.Add(DateTimeValueHere)

You should be fine then.

HTH,

Bill
 
William,
But I was using parameter objects and they don't work either (for datetime
values). I cannot get the paremeters values or the straight SQL to work with
datetime values. Now just dates -- they work. Why don't datetime values
work? Why does not VS.NET generate datetime values when it sees that access
has defined a timestamp?
Sieg
 
Back
Top