BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Re: Data Type Mismatch Access TADOQuery DateTime

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> comp.lang.pascal.delphi.databases
View previous topic :: View next topic  
Author Message
Dan
Guest





PostPosted: Tue Feb 03, 2004 7:48 pm    Post subject: Re: Data Type Mismatch Access TADOQuery DateTime Reply with quote



On Mon, 2 Feb 2004 19:35:14 -0000, "G Smith" <g.smith2 (AT) ntlworld (DOT) com>
wrote:

Quote:
Hi,

Im quite new to delphi and am experiencing the following problem.

Im using a TADOQuery to retrieve a date from a Access database and then wish
to use it again in another sql query, but i am getting data mismatch
exceptions.


q4.sql.text := 'SELECT (SELECT max(DateTimeMod) from LOTracking where
(LOTracking.LOID) = '+inttostr(q.fieldvalues['ID'])+') as LVDate from
LOTracking where (LOTracking.LOID) = '+inttostr(q.fieldvalues['ID']);
q4.open;


q5.sql.text := 'SELECT LOTracking.PersonID from LOTracking where
(LOTracking.LOID = '+inttostr(q.fieldvalues['ID']) +') and
(LOTracking.DateTimeMod = '''+datetimetostr(q4.fieldvalues['LVDate'])+''')';

I'm not a user of ADO, so this may be way off.
One often used method is to have a parameter for the datetime value,
rather than trying to explicitly format it. So you would have:

(LOTracking.DateTimeMod = :dtime)
q5.parambyname('dtime').AsDateTime :=
q4.FieldByName('LVDate').AsDateTime;
Quote:
q5.open;

This method usually solves mismatch problems for me.


HTH,
Dan

Quote:
The DateTimeMod field is General Date Time format. When using the delphi
debugger to view the LVDate it is identical to that in the database and
should work.


Any help would be much appreciated,



Thanks




Back to top
G Smith
Guest





PostPosted: Wed Feb 04, 2004 9:12 pm    Post subject: Re: Data Type Mismatch Access TADOQuery DateTime Reply with quote



Thanks a lot seems to work perfectly !


"Dan" <Doculus at CMDCsystems dot com> wrote

Quote:
On Mon, 2 Feb 2004 19:35:14 -0000, "G Smith" wrote:

Hi,

Im quite new to delphi and am experiencing the following problem.

Im using a TADOQuery to retrieve a date from a Access database and then
wish
to use it again in another sql query, but i am getting data mismatch
exceptions.


q4.sql.text := 'SELECT (SELECT max(DateTimeMod) from LOTracking where
(LOTracking.LOID) = '+inttostr(q.fieldvalues['ID'])+') as LVDate from
LOTracking where (LOTracking.LOID) = '+inttostr(q.fieldvalues['ID']);
q4.open;


q5.sql.text := 'SELECT LOTracking.PersonID from LOTracking where
(LOTracking.LOID = '+inttostr(q.fieldvalues['ID']) +') and
(LOTracking.DateTimeMod =
'''+datetimetostr(q4.fieldvalues['LVDate'])+''')';

I'm not a user of ADO, so this may be way off.
One often used method is to have a parameter for the datetime value,
rather than trying to explicitly format it. So you would have:

(LOTracking.DateTimeMod = :dtime)
q5.parambyname('dtime').AsDateTime :=
q4.FieldByName('LVDate').AsDateTime;
q5.open;

This method usually solves mismatch problems for me.

HTH,
Dan

The DateTimeMod field is General Date Time format. When using the delphi
debugger to view the LVDate it is identical to that in the database and
should work.


Any help would be much appreciated,



Thanks






Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> comp.lang.pascal.delphi.databases All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.