🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.database.ado
3 messages
3 total messages Started by PS Tue, 01 Aug 2000 00:00
MS Access : 'Data type mismatch in criteria expression'
#6097
Author: PS
Date: Tue, 01 Aug 2000 00:00
20 lines
1491 bytes
I am using an ADO connection to an Access DB.
I have a TADOQuery along the lines of:

UPDATE Engineers SET Available = :LOGON, LastLogonOff = :TIMESTAMP WHERE
EngineerID = :_SOURCE

Where Engineers table fields are Available = Yes/No (True/False),
LastLogonOff = Date/Time and EngineerID = Text.

The parameter data is set to 'bool', 'TDateTime' and 'AnsiString' using a
Variant type.

The first time the query is run, it works fine.
The second time the query is run I get a 'Data type mismatch in criteria
expression' error.

The same code works fine into a SQL 7 database of a similar structure.

Thanks in advance,
Paul Stables.
Re: MS Access : 'Data type mismatch in criteria expression'
#6098
Author: PS
Date: Tue, 01 Aug 2000 00:00
28 lines
1908 bytes
I have done some experimenting and if I set the Parameter DataType each time
instead of once when the query is set up then it fixes the problem. Why is
my query losing it's parameter data on Access DB's?

"PS" <paul@nospam.stables1.freeserve.co.uk> wrote in message
news:8m63pr$29f$1@newsreaderg1.core.theplanet.net...
> I am using an ADO connection to an Access DB.
> I have a TADOQuery along the lines of:
>
> UPDATE Engineers SET Available = :LOGON, LastLogonOff = :TIMESTAMP WHERE
> EngineerID = :_SOURCE
>
> Where Engineers table fields are Available = Yes/No (True/False),
> LastLogonOff = Date/Time and EngineerID = Text.
>
> The parameter data is set to 'bool', 'TDateTime' and 'AnsiString' using a
> Variant type.
>
> The first time the query is run, it works fine.
> The second time the query is run I get a 'Data type mismatch in criteria
> expression' error.
>
> The same code works fine into a SQL 7 database of a similar structure.
>
> Thanks in advance,
> Paul Stables.
>
>
Re: MS Access : 'Data type mismatch in criteria expression'
#6099
Author: PS
Date: Tue, 01 Aug 2000 00:00
48 lines
2587 bytes
More testing...
After the initial setup of the parameter type, each time I run the query I
set each Parameters DataType & Direction to what it's current value is, i.e.

    for (int i=0; i<Query->Parameters->Count; i++)
    {
        Query->Parameters->Items[i]->DataType =
Query->Parameters->Items[i]->DataType;
        Query->Parameters->Items[i]->Direction =
Query->Parameters->Items[i]->Direction;
    }

Then this fixes the problem!

"PS" <paul@nospam.stables1.freeserve.co.uk> wrote in message
news:8m6869$49j$1@newsreaderg1.core.theplanet.net...
> I have done some experimenting and if I set the Parameter DataType each
time
> instead of once when the query is set up then it fixes the problem. Why is
> my query losing it's parameter data on Access DB's?
>
> "PS" <paul@nospam.stables1.freeserve.co.uk> wrote in message
> news:8m63pr$29f$1@newsreaderg1.core.theplanet.net...
> > I am using an ADO connection to an Access DB.
> > I have a TADOQuery along the lines of:
> >
> > UPDATE Engineers SET Available = :LOGON, LastLogonOff = :TIMESTAMP WHERE
> > EngineerID = :_SOURCE
> >
> > Where Engineers table fields are Available = Yes/No (True/False),
> > LastLogonOff = Date/Time and EngineerID = Text.
> >
> > The parameter data is set to 'bool', 'TDateTime' and 'AnsiString' using
a
> > Variant type.
> >
> > The first time the query is run, it works fine.
> > The second time the query is run I get a 'Data type mismatch in criteria
> > expression' error.
> >
> > The same code works fine into a SQL 7 database of a similar structure.
> >
> > Thanks in advance,
> > Paul Stables.
> >
> >
>
>
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads