PC Review


Reply
Thread Tools Rate Thread

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

 
 
Siegfried Heintze
Guest
Posts: n/a
 
      17th Mar 2004
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


 
Reply With Quote
 
 
 
 
William Ryan eMVP
Guest
Posts: n/a
 
      17th Mar 2004
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



"Siegfried Heintze" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
Siegfried Heintze
Guest
Posts: n/a
 
      17th Mar 2004
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
"William Ryan eMVP" <(E-Mail Removed)> wrote in message
news:#(E-Mail Removed)...
> 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
>
>
>
> "Siegfried Heintze" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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
> >
> >

>
>



 
Reply With Quote
 
Miha Markic [MVP C#]
Guest
Posts: n/a
 
      17th Mar 2004
Hi Siegfried,

Try setting parameter as OleDbType.Date.

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

"Siegfried Heintze" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
> "William Ryan eMVP" <(E-Mail Removed)> wrote in message
> news:#(E-Mail Removed)...
> > 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
> >
> >
> >
> > "Siegfried Heintze" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > 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
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Difference between two datetimes Sheldon Microsoft VB .NET 2 10th Nov 2008 02:01 PM
Best way for compare Nullable Datetimes Alhambra Eidos Kiquenet Microsoft ASP .NET 0 7th Feb 2008 11:34 AM
day-difference between 2 datetimes Daves Microsoft C# .NET 4 15th Sep 2006 02:26 PM
Best way to handle datetimes for any culture? =?Utf-8?B?Um9iZXJ0IFcu?= Microsoft C# .NET 5 22nd Jun 2006 05:58 PM
Problem with datetimes in SQL CE.Need help. jorgeo Microsoft Dot NET Compact Framework 4 1st Aug 2003 09:42 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:46 PM.