Question

I want to run a simple SQL from Delphi 2007.

I use AdoQuery. My table has a column id and data type is int (autoincrement).

My question is if I execute

select * from comlist

there is no problem, it runs. But if I define a field on SQL like

select compname from comlist

Delphi complains

ado:Field 'id' not found

The Compname column exist in table.

I have the following fields on my table:

id int
creationdate datetime
compid nvarcahr(50)
complocation nvarchar(50)
serial nvarchar(50) 
compname nvarchar(50)

I have error with this code:

ado.Close;
ado.SQL.Clear;
ado.SQL.Add('SELECT   compname  FROM comlist');
ado.Open;

I have no error with this code:

ado.Close;
ado.SQL.Clear;
ado.SQL.Add('SELECT * FROM comlist');
ado.Open;

What could be the problem?

Was it helpful?

Solution

You might have fields defined in your query component. Select ADOQuery component and open Fields editor from context menu and remove fields.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top