field name missing

field name missing

Post by nospam_kan » Wed, 08 Dec 2004 11:45:00


D7, IB 6.0.2.0, dbExpress, Midas, 3T-CS

I'm trying to pass the following statement through my TClientDataSet
to an TSQLQuery:

SELECT FIELD1, FIELD2, 'VEGAS', FIELD3, FIELD4
FROM TABLE1

When I execute this statement in IBConsole, it works great. The third
field is just a column of text that says VEGAS.

However this exact same statement causes an error to be raised in my
application. The text in the error is:

field name missing

I'm passing the statement thus:

...
var city_name: String;
...
city_name := 'VEGAS';

with cdsCity do
begin
Close;
CommandText :=
'SELECT FIELD1, FIELD2, ' + QuotedStr(city_name) + ', FIELD3,
FIELD4
FROM TABLE1';
Open;
end;

Error occurs at the "Open" line. (Be aware that the CommandText line
doesn't word wrap in Delphi as it's shown in this email)

What am I doing wrong?

Thanks in advance.
 
 
 

field name missing

Post by David Lewi » Thu, 09 Dec 2004 03:58:05

I don't know if this is your problem, but I think maybe its because you have
to give the string value an actual column / field name. So change your code
to ( where "CITY" is the name that I'm typecasting to - it can obviously be
called anything ).

CommandText := 'SELECT FIELD1, FIELD2, ' + QuotedStr( CityName ) + '
"CITY", FIELD3, FIELD4 FROM TABLE1';