PC Review


Reply
Thread Tools Rate Thread

DataTime Problem

 
 
Jacko
Guest
Posts: n/a
 
      5th Jun 2009
Hi,

I had inserted in a Access Db in field of type DateTime the value
DateTime.Today (OleDb)

Later my client suggested they needed the Time as well in the field, so i
changed to DateTime.Now and it threw up an error.

Since both DateTime.Today and DateTime.Now are of type DateTime why do i get
a error?

TIA
Barry



 
Reply With Quote
 
 
 
 
Jacko
Guest
Posts: n/a
 
      5th Jun 2009
cmd.Parameters.Add(@SendDate, DateTime.Today); // This work

cmd.Parameters.Add(@SendDate, DateTime.Now); // This show an error

cmd above is OleDbCommand

Does this answer your question??



"Patrice" <http://www.chez.com/scribe/> wrote in message
news:7878942D-AE92-4719-94B5-(E-Mail Removed)...
> Please never talk about an error without posting the exact error message
> !!! This is your fist diagnosis tool...
>
> Generally the few lines above the error ending with the offending line are
> also usefull...
>
> How do you send data to the db ? If using a plain text SQL statement it
> could be liekly that the date format is not valid. Using parametized query
> is likely your best bet...
>
>
>
> --
> Patrice
>
>
> "Jacko" <(E-Mail Removed)> a écrit dans le message de groupe de
> discussion : #(E-Mail Removed)...
>> Hi,
>>
>> I had inserted in a Access Db in field of type DateTime the value
>> DateTime.Today (OleDb)
>>
>> Later my client suggested they needed the Time as well in the field, so i
>> changed to DateTime.Now and it threw up an error.
>>
>> Since both DateTime.Today and DateTime.Now are of type DateTime why do i
>> get a error?
>>
>> TIA
>> Barry
>>
>>
>>

>



 
Reply With Quote
 
Jacko
Guest
Posts: n/a
 
      6th Jun 2009
I posted my previous reply thinking that you are an expert, unfortunately
you don't seem to be one.


"Patrice" <http://www.chez.com/scribe/> wrote in message
newsE0A7510-A974-4A88-9FD8-(E-Mail Removed)...
> And the error message is ? Could it be that the precision used by .NET
> exceed the precision used by Access for string Datetimes ?...
>
> --
> Patrice
>
>
> "Jacko" <(E-Mail Removed)> a écrit dans le message de groupe de
> discussion : #(E-Mail Removed)...
>> cmd.Parameters.Add(@SendDate, DateTime.Today); // This work
>>
>> cmd.Parameters.Add(@SendDate, DateTime.Now); // This show an error
>>
>> cmd above is OleDbCommand
>>
>> Does this answer your question??
>>
>>
>>
>> "Patrice" <http://www.chez.com/scribe/> wrote in message
>> news:7878942D-AE92-4719-94B5-(E-Mail Removed)...
>>> Please never talk about an error without posting the exact error message
>>> !!! This is your fist diagnosis tool...
>>>
>>> Generally the few lines above the error ending with the offending line
>>> are also usefull...
>>>
>>> How do you send data to the db ? If using a plain text SQL statement it
>>> could be liekly that the date format is not valid. Using parametized
>>> query is likely your best bet...
>>>
>>>
>>>
>>> --
>>> Patrice

>>

>



 
Reply With Quote
 
Jacko
Guest
Posts: n/a
 
      7th Jun 2009

It seems like, Patrice has a lot quite a few friends/admirers here.

You guys should note that when someone posts a message here he/she assumes
that the info posted is sufficent for others to understand, what the problem
is all about, i do not think anyone will post a message knowing well that
the message will not get any replies.

I had solved the problem in a round-about way, much before i posted the
message, my idea of posting this message was to get it across to those who
may be interested to know that there is a problem either in MS Access or
..NET Framework.

The code was part of a large app and going back to the app just to reproduce
the exact error message would have taken me hours of work, and that was not
worth the effort of posting this message.

The error message as far as i can recollect was something similar to "Data
type mismatch".

There are many way of asking question, some of them can by themselves be
insulting in nature.


"Mark Rae [MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "Jacko" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>
>> cmd.Parameters.Add(@SendDate, DateTime.Now); // This show an error

>
> See, the thing here is that you have been asked more than once to tell the
> group what the error actually is? If you do that, then people will be able
> to help you...
>
> Are you deliberately not telling the group what the error is...?
>
>
> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net



 
Reply With Quote
 
Family Tree Mike
Guest
Posts: n/a
 
      7th Jun 2009
"Jacko" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> ...
>
> I had solved the problem in a round-about way, much before i posted the
> message, my idea of posting this message was to get it across to those who
> may be interested to know that there is a problem either in MS Access or
> .NET Framework.
>


So now someone with the problem you described will not know how you solved
it. Frequently people find these posts when searching for similar problems.


>
> The code was part of a large app and going back to the app just to
> reproduce the exact error message would have taken me hours of work, and
> that was not worth the effort of posting this message.
>


Until now you never claimed you had got the code to work. In fact, you
actually posted code you said failed.

It was apparent from your post you were asking for help, not that you were
trying to help others. Note that your first post include "Since both
DateTime.Today and DateTime.Now are of type DateTime why do i get a error?",
not "...why did I get an error?".

--
Mike

 
Reply With Quote
 
Jacko
Guest
Posts: n/a
 
      7th Jun 2009

I do not find anything insufficent or incorrect in my replies so far,
irrespective of how many friend or admirers Patrice has, the only mistake i
could have made is that i did not not mention that i had solved the problem,
in my initial posting.


"Peter Duniho" <(E-Mail Removed)> wrote in message
news(E-Mail Removed)...
> On Sat, 06 Jun 2009 17:17:33 -0700, Jacko <(E-Mail Removed)> wrote:
>
>>
>> It seems like, Patrice has a lot quite a few friends/admirers here.

>
> You write that as if it's a bad thing. Though, to be clear...I can't say
> that there are any really close relationships between people following
> this newsgroup. What I can say is that we expect people asking questions
> to ask answerable questions, to provide additional details when requested,
> and to not exhibit hostility when they are asked for those additional
> details.
>
>> You guys should note that when someone posts a message here he/she
>> assumes
>> that the info posted is sufficent for others to understand, what the
>> problem
>> is all about, i do not think anyone will post a message knowing well that
>> the message will not get any replies.

>
> You should note that when someone replies to a question you've posted
> here, there is the implicit assumption that the person who replied is
> trying to be helpful.
>
> It's clear what assumptions you made. The problem is that even after it
> was pointed out to you that your assumptions were incorrect, you failed to
> correct those assumptions and elaborate on your question. Your further
> hostility in the face of additional reminders of your incorrect
> assumptions suggest that rather than looking to get an answer to your
> question, you would prefer to be abusive.
>
> After all, a person who wanted an actual answer would just provide the
> additional information requested.
>
>> I had solved the problem in a round-about way, much before i posted the
>> message, my idea of posting this message was to get it across to those
>> who
>> may be interested to know that there is a problem either in MS Access or
>> .NET Framework.

>
> No one reading this message thread will have any clue whatsoever what
> problem you had, never mind in what component it exists or how to work
> around it.
>
>> The code was part of a large app and going back to the app just to
>> reproduce
>> the exact error message would have taken me hours of work, and that was
>> not
>> worth the effort of posting this message. [...]

>
> Then you are wasting everyone's time. Please don't do that.
>
> If it's not worth your time to provide an answerable question, then it's
> not worth anyone else's time to try to answer your question.
>
> Pete



 
Reply With Quote
 
Jacko
Guest
Posts: n/a
 
      7th Jun 2009

I did not know that besides programmer, this forum also has people from the
Legal faternity, those who try to find words between sentences like "do /
did".

Hence forth i may need to get my messages verified by a legal expert before
posting it here.


"Family Tree Mike" <(E-Mail Removed)> wrote in message
news976FC73-9FA2-4473-AF94-(E-Mail Removed)...
> "Jacko" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>>
>> ...
>>
>> I had solved the problem in a round-about way, much before i posted the
>> message, my idea of posting this message was to get it across to those
>> who may be interested to know that there is a problem either in MS Access
>> or .NET Framework.
>>

>
> So now someone with the problem you described will not know how you solved
> it. Frequently people find these posts when searching for similar
> problems.
>
>
>>
>> The code was part of a large app and going back to the app just to
>> reproduce the exact error message would have taken me hours of work, and
>> that was not worth the effort of posting this message.
>>

>
> Until now you never claimed you had got the code to work. In fact, you
> actually posted code you said failed.
>
> It was apparent from your post you were asking for help, not that you were
> trying to help others. Note that your first post include "Since both
> DateTime.Today and DateTime.Now are of type DateTime why do i get a
> error?", not "...why did I get an error?".
>
> --
> Mike



 
Reply With Quote
 
Jacko
Guest
Posts: n/a
 
      10th Jun 2009
Finally, thanks.

I did use "Add" not "AddWithValue" since the project was developed in VS
2003 .NET Framework 1.1 (forgot to mention this in my original posting),
maybe there was some update in .Net Framework 2.0, which permits both to
work.

This is what i did to get around the problem

cmd.Parameters.Add("@SendDate", OleDbType.DateTime).Value = new
DateTime(year, month, day, hours, minutes, seconds); // these values are of
DateTime.Today

Note: I had solved the issue before posting the original message, it was
only meant as a message to those who matter.


"Patrice" <http://www.chez.com/scribe/> wrote in message
news:EEC48081-D3CA-4C72-9824-(E-Mail Removed)...
> Tried a repro and works fine here in both cases. I assume you are using
> AddWithValue as "Add" wouldn't compile...
>
> This is where the error message would be usefull as your code (or
> something very similar works fine here).
>
> --
> Patrice
>
>
> "Patrice" <http://www.chez.com/scribe/> a écrit dans le message de groupe
> de discussion : 1D278DCB-1025-42D4-AB1E-(E-Mail Removed)...
>> I asked also the error message which should be always the starting point
>> when something goes wrong. The code you posted seems legal and the only
>> difference is the precision (Now includes the time while Today doesn't)
>>
>> IMO this is a precision problem (i.e. the DateTime field uses by Access
>> is not precise enough to handle the DateTime .NET type). I would try to
>> drop the milliseconds to see if it solves the problem.
>>
>>
>> --
>> Patrice
>>
>> "Jacko" <(E-Mail Removed)> a écrit dans le message de groupe de
>> discussion : #(E-Mail Removed)...
>>> I posted my previous reply thinking that you are an expert,
>>> unfortunately you don't seem to be one.
>>>

>>
>>
>>

>



 
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
DataTime - TryParseExact Brian R. Microsoft C# .NET 3 2nd Oct 2008 03:56 PM
datatime fields Microsoft C# .NET 1 14th Apr 2008 08:31 PM
DataTime in excel =?Utf-8?B?SklNLkgu?= Microsoft Excel Misc 2 18th Sep 2007 04:39 AM
DataTime string format barry Microsoft ASP .NET 4 14th Feb 2006 04:12 PM
DataTime Picker with API Steve Conklin \(Dev@UltraDNT\) Microsoft Access Form Coding 2 21st May 2004 07:51 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:22 PM.