Board index » delphi » Query:Field 'fieldname' not found

Query:Field 'fieldname' not found

I'm trying to use a TQuery to select the number of records in a Paradox 4
table which has 4 fields:  NUMBER  N  ITEM  A 6  QUANT  N  VALUE  $ The key
is NUMBER+ITEM. The SQL used is "select count (distinct numero) from <table
name> where item <> '999997'". The Query runs ok, but when I try to open a
report with its result, an exception is raised, with the message
"...EDatabaseError ... <query name>:Field 'number' not found ..." Does
anybody have an idea of what I'm doing wrong? Thanks, Rogerio

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum

 

Re:Query:Field 'fieldname' not found


Rogerio,

It's not advisable to use names like Number and Value for fields -
treat them as reserved words.
However, it should work if you do this:

    Select count(distinct T."Number") from <TableName> T

    Stephen
--
Stephen Brown
+44 (0)171 704 0702
sbr...@sprocket.win-uk.net

Quote
rogeriocu...@my-dejanews.com wrote in message

<6qv0gk$vt...@nnrp1.dejanews.com>...
Quote
>I'm trying to use a TQuery to select the number of records in a
Paradox 4
>table which has 4 fields:  NUMBER  N  ITEM  A 6  QUANT N  VALUE  $
The key
>is NUMBER+ITEM. The SQL used is "select count (distinct numero) from
<table
>name> where item <> '999997'". The Query runs ok, but when I try to
open a
>report with its result, an exception is raised, with the message
>"...EDatabaseError ... <query name>:Field 'number' not found ..."
Does
>anybody have an idea of what I'm doing wrong? Thanks, Rogerio

Re:Query:Field 'fieldname' not found


Hi Rogrio,

This error states that the field doesn't exist in the dataset. You have
written  numero and number in your message. Which one is in your dataset. You
said the sql runs OK so the error occur probably when you reference the field
in the report.

Voc brasileiro ?

Best Regards

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum

Re:Query:Field 'fieldname' not found


Quote
rogeriocu...@my-dejanews.com wrote:
> I'm trying to use a TQuery to select the number of records in a Paradox 4
> table which has 4 fields:  NUMBER  N  ITEM  A 6  QUANT  N  VALUE  $ The key
> is NUMBER+ITEM. The SQL used is "select count (distinct numero) from <table
> name> where item <> '999997'". The Query runs ok, but when I try to open a
> report with its result, an exception is raised, with the message
> "...EDatabaseError ... <query name>:Field 'number' not found ..." Does
> anybody have an idea of what I'm doing wrong? Thanks, Rogerio

Number field will not be in the result set, there will (probably) be field
COUNT. You can use: SELECT COUNT( fieldname ) AS anewfieldname, to get a
different name to refer to in the report.

--
Kari Heinonen / Veikko Heinonen Oy

http://personal.inet.fi/koti/veikko.heinonen/

Other Threads