Board index » delphi » TQuery Component gives unknown Identifier error

TQuery Component gives unknown Identifier error

It might be as simple as I do not include some BDE file in
the installation but nevertheless I am totally perplexed. I
have a TQuery component that its entire function is to
return the count of number of records with a certain field
set:

select count(ID) from App
where status='R'

In TQuery fields editor I right-clicked on add fields and it
gave me a single COUNT_OF_I field available. I use it to
find how many records to transmit

NumTransmit:=dbQueryCOUNT_OF_I.asInteger;

On my computer it works fine. No error messages but after I
install the program (InstallShield Express 2.12, NOT the
Delphi limeted edition) on the user's machine they receive
an error

dbQuery: Field 'COUNT_OF_I' not found

This code did not change from version 1 of Delphi but only
in Delphi 5 we get this error and only on the user's machine

Please help. I am desperate. I tried everything and now out
of ideas.

Anita-Maria

 

Re:TQuery Component gives unknown Identifier error


Did you try something like this:  Select count(ID) as ID_COUNT ?  It
works with paradox and the TQuery object will give you a TField named
ID_COUNT since it's aliased in the SQL statement.

HTH,

Michael

Quote
"Anita-Maria K. Parolla" wrote:
> It might be as simple as I do not include some BDE file in
> the installation but nevertheless I am totally perplexed. I
> have a TQuery component that its entire function is to
> return the count of number of records with a certain field
> set:

> select count(ID) from App
> where status='R'

> In TQuery fields editor I right-clicked on add fields and it
> gave me a single COUNT_OF_I field available. I use it to
> find how many records to transmit

> NumTransmit:=dbQueryCOUNT_OF_I.asInteger;

> On my computer it works fine. No error messages but after I
> install the program (InstallShield Express 2.12, NOT the
> Delphi limeted edition) on the user's machine they receive
> an error

> dbQuery: Field 'COUNT_OF_I' not found

> This code did not change from version 1 of Delphi but only
> in Delphi 5 we get this error and only on the user's machine

> Please help. I am desperate. I tried everything and now out
> of ideas.

> Anita-Maria

Re:TQuery Component gives unknown Identifier error


Yes, But then I get another stupid message that does not mean anything:

dbQuery: Type mismatch for field 'ID_COUNT', expecting: Float actual
Integer

and why there is no error on my machine but the only on the users'
machines. and there is the wierdest thing of all: the variable
appID_COUNT (or appCOUNT_OF_I) is assigned to
(NumTransmit:=dbQueryID_COUNT.asInteger;) does get the proper value. the
error happens only when setting dbQuery.Active:=true;. And the most
buffling is the SQL statement is modified a little later on in the code
so before hand I set Active to false and then after the modification to
true again but the message does not come second time

Thank you very much for your help. this one really drives me insane

Anita-Maria

Quote
Michael Glatz wrote:
> Did you try something like this:  Select count(ID) as ID_COUNT ?  It
> works with paradox and the TQuery object will give you a TField named
> ID_COUNT since it's aliased in the SQL statement.

> HTH,

> Michael

> "Anita-Maria K. Parolla" wrote:

> > It might be as simple as I do not include some BDE file in
> > the installation but nevertheless I am totally perplexed. I
> > have a TQuery component that its entire function is to
> > return the count of number of records with a certain field
> > set:

> > select count(ID) from App
> > where status='R'

> > In TQuery fields editor I right-clicked on add fields and it
> > gave me a single COUNT_OF_I field available. I use it to
> > find how many records to transmit

> > NumTransmit:=dbQueryCOUNT_OF_I.asInteger;

> > On my computer it works fine. No error messages but after I
> > install the program (InstallShield Express 2.12, NOT the
> > Delphi limeted edition) on the user's machine they receive
> > an error

> > dbQuery: Field 'COUNT_OF_I' not found

> > This code did not change from version 1 of Delphi but only
> > in Delphi 5 we get this error and only on the user's machine

> > Please help. I am desperate. I tried everything and now out
> > of ideas.

> > Anita-Maria

Re:TQuery Component gives unknown Identifier error


On Wed, 22 Dec 1999 10:59:55 -0500, "Anita-Maria K. Parolla"

Quote
<point...@erols.com> wrote:
>Yes, But then I get another stupid message that does not mean anything:

>dbQuery: Type mismatch for field 'ID_COUNT', expecting: Float actual
>Integer

>and why there is no error on my machine but the only on the users'
>machines. and there is the wierdest thing of all: the variable
>appID_COUNT (or appCOUNT_OF_I) is assigned to
>(NumTransmit:=dbQueryID_COUNT.asInteger;) does get the proper value. the
>error happens only when setting dbQuery.Active:=true;. And the most
>buffling is the SQL statement is modified a little later on in the code
>so before hand I set Active to false and then after the modification to
>true again but the message does not come second time

I agree with Michael that you need to give an alias for aggregate
fields in a TQuery.  This is always a good habit.

As to why you machine gives different results for the same query, the
only logical explanation can be a different version of the BDE, or -
more likely - different BDE settings (like default table level).

If you want to avoid type mismatches in this case, you can either
specify the type in the query too:
  select Cast(Count(ID) as Integer) from theTable

But this doesn't strike me as very elegant.  The alternative is not to
use persistent fields at all for such a simple query and get the value
like this:
  TheValue := Query1.Fields[0].AsInteger;

Jan

Re:TQuery Component gives unknown Identifier error


Thanks everybody who tried to help me on this issue. The problem is not over.
I just took a little hiatus from it because it was driving me insane.

I corrected the  SQL string as per

select Count(ID) as ID_COUNT from App
where status='R'

but this time, In TQuery fields editor I right-clicked on new fields instead
of adding the available ID_COUNT, I defined a new field (as integer) with the
same name ID_COUNT and FieldKind fkData but the Type is Integer (when
selected automaticaly he defines as FloatField). Now on my machine I get the
error

dbQuery: Type mismatch for field 'ID_COUNT', expecting: Integer actual
Float.

But on my users machines there is no problem.
(Jan, the cast call did not help. The "other" machine ignored it)
I also copied the BDE from my machine to the test machine. It did not solve
the problem.

Please help!!!

Anita-Maira

Quote
Jan Sprengers wrote:
> On Wed, 22 Dec 1999 10:59:55 -0500, "Anita-Maria K. Parolla"
> <point...@erols.com> wrote:

> >Yes, But then I get another stupid message that does not mean anything:

> >dbQuery: Type mismatch for field 'ID_COUNT', expecting: Float actual
> >Integer

> >and why there is no error on my machine but the only on the users'
> >machines. and there is the wierdest thing of all: the variable
> >appID_COUNT (or appCOUNT_OF_I) is assigned to
> >(NumTransmit:=dbQueryID_COUNT.asInteger;) does get the proper value. the

> I agree with Michael that you need to give an alias for aggregate
> fields in a TQuery.  This is always a good habit.

> As to why you machine gives different results for the same query, the
> only logical explanation can be a different version of the BDE, or -
> more likely - different BDE settings (like default table level).

> If you want to avoid type mismatches in this case, you can either
> specify the type in the query too:
>   select Cast(Count(ID) as Integer) from theTable

> But this doesn't strike me as very elegant.  The alternative is not to
> use persistent fields at all for such a simple query and get the value
> like this:
>   TheValue := Query1.Fields[0].AsInteger;

> Jan

Re:TQuery Component gives unknown Identifier error


OK, Here is the latest and the greatest.
I used the cast statement but I casted it as Float.

select Cast(Count(ID) as Float) as ID_COUNT from theTable
where status='R'

(btw, ID is a float field)
This time it worked on both my machine and the test machine.

So I am very grateful to everybody who helped but now I am curious to why.
Will really appreciate your help. This problem drove me insane and I am half
head bold. So if at least I can learn something here I will not be so sorry
for all those hair :-)

Anita-Maria

Quote
Jan Sprengers wrote:
> On Wed, 22 Dec 1999 10:59:55 -0500, "Anita-Maria K. Parolla"
> <point...@erols.com> wrote:

> >Yes, But then I get another stupid message that does not mean anything:

> >dbQuery: Type mismatch for field 'ID_COUNT', expecting: Float actual
> >Integer

> >and why there is no error on my machine but the only on the users'
> >machines. and there is the wierdest thing of all: the variable
> >appID_COUNT (or appCOUNT_OF_I) is assigned to
> >(NumTransmit:=dbQueryID_COUNT.asInteger;) does get the proper value. the
> >error happens only when setting dbQuery.Active:=true;. And the most
> >buffling is the SQL statement is modified a little later on in the code
> >so before hand I set Active to false and then after the modification to
> >true again but the message does not come second time

> I agree with Michael that you need to give an alias for aggregate
> fields in a TQuery.  This is always a good habit.

> As to why you machine gives different results for the same query, the
> only logical explanation can be a different version of the BDE, or -
> more likely - different BDE settings (like default table level).

> If you want to avoid type mismatches in this case, you can either
> specify the type in the query too:
>   select Cast(Count(ID) as Integer) from theTable

> But this doesn't strike me as very elegant.  The alternative is not to
> use persistent fields at all for such a simple query and get the value
> like this:
>   TheValue := Query1.Fields[0].AsInteger;

> Jan

Re:TQuery Component gives unknown Identifier error


On Wed, 05 Jan 2000 18:17:51 -0500, "Anita-Maria K. Parolla"

Quote
<point...@erols.com> wrote:
>select Cast(Count(ID) as Float) as ID_COUNT from theTable
>where status='R'

>(btw, ID is a float field)
>This time it worked on both my machine and the test machine.

The field type of ID shouldn't matter for the expression.

Quote
>Will really appreciate your help. This problem drove me insane and I am half
>head bold. So if at least I can learn something here I will not be so sorry
>for all those hair :-)

What is the default table level for the Paradox driver in the BDE
Administrator on your machine and your user's?

Jan

Re:TQuery Component gives unknown Identifier error


it is not paradox. it is dbase. AM
Quote
Jan Sprengers wrote:
> On Wed, 05 Jan 2000 18:17:51 -0500, "Anita-Maria K. Parolla"
> <point...@erols.com> wrote:

> >select Cast(Count(ID) as Float) as ID_COUNT from theTable
> >where status='R'

> >(btw, ID is a float field)
> >This time it worked on both my machine and the test machine.

> The field type of ID shouldn't matter for the expression.

> >Will really appreciate your help. This problem drove me insane and I am half
> >head bold. So if at least I can learn something here I will not be so sorry
> >for all those hair :-)

> What is the default table level for the Paradox driver in the BDE
> Administrator on your machine and your user's?

> Jan

Re:TQuery Component gives unknown Identifier error


On Thu, 13 Jan 2000 16:23:32 -0500, "Anita-Maria K. Parolla"

Quote
<point...@erols.com> wrote:
>it is not paradox. it is dbase. AM

So: what is the default table level for the dBase driver in the BDE
Administrator on your machine and your user's?

Jan

Re:TQuery Component gives unknown Identifier error


Excuse the ignorance please what is default table lavel and how do I
find where it is? AM
Quote
Jan Sprengers wrote:
> On Thu, 13 Jan 2000 16:23:32 -0500, "Anita-Maria K. Parolla"
> <point...@erols.com> wrote:

> >it is not paradox. it is dbase. AM

> So: what is the default table level for the dBase driver in the BDE
> Administrator on your machine and your user's?

> Jan

Re:TQuery Component gives unknown Identifier error


Quote
>Excuse the ignorance please what is default table lavel

The level of table that BDE creates if you do not specify a level with the
tableLevel property.
Note that when you create a table it will always have to have a level high
enough to support the features you create it with.

Quote
>>and how do I
>find where it is? AM

It is set in the BDE configuration file.  Run BDEAdmin.exe
--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Re:TQuery Component gives unknown Identifier error


On Fri, 14 Jan 2000 13:19:21 -0500, "Anita-Maria K. Parolla"

Quote
<point...@erols.com> wrote:
>Excuse the ignorance please what is default table lavel and how do I
>find where it is? AM

Start the BDE Administrator program that you find on your Control
Panel.  On the right tab (Configuration) you find Configuration |
Drivers | Native | DBASE.  On the right hand side, you now see LEVEL.
That's the default table level for DBase tables.  The table level
designates the 'version' of the file you're creating: 3 for DBase
III+, 4 for DBase IV and so on.

As Brian said, this is the level that is used to create a table via
TTable.CreateTable when TableLevel is not set, but - more importantly
in this case - it is also the table level that is used to create
temporary query result tables.  Because higher versions support more
data types then prior versions (e.g. Float, Double, Long), it is well
possible that depending on the default table level, another data type
is selected.

HTH,

Jan

Re:TQuery Component gives unknown Identifier error


OK, found. Thanks. It is 5 (can go as high as 7). AM
Quote
Jan Sprengers wrote:
> On Fri, 14 Jan 2000 13:19:21 -0500, "Anita-Maria K. Parolla"
> <point...@erols.com> wrote:

> >Excuse the ignorance please what is default table lavel and how do I
> >find where it is? AM

> Start the BDE Administrator program that you find on your Control
> Panel.  On the right tab (Configuration) you find Configuration |
> Drivers | Native | DBASE.  On the right hand side, you now see LEVEL.
> That's the default table level for DBase tables.  The table level
> designates the 'version' of the file you're creating: 3 for DBase
> III+, 4 for DBase IV and so on.

> As Brian said, this is the level that is used to create a table via
> TTable.CreateTable when TableLevel is not set, but - more importantly
> in this case - it is also the table level that is used to create
> temporary query result tables.  Because higher versions support more
> data types then prior versions (e.g. Float, Double, Long), it is well
> possible that depending on the default table level, another data type
> is selected.

> HTH,

> Jan

Other Threads