SQL syntax error

馋奶兔 提交于 2019-12-13 04:38:30

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/18760868/sql-syntax-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!