我用ADOQuery连接Access数据库,查询数值型的字段就能查出记录,查询字符型字段时就会出错,什么“参数不足,期待是1”。
所用语句如下:
var
  string1:string;
begin
  inherited;
  if ConnectDataBase then
begin
  ADOQuery1.Close;
  ADOQuery1.SQL.Clear;
  string1:='select * from Component where ComName=a2';
  ADOQuery1.SQL.Add(string1);
  ADOQuery1.Open;
end;
end;
其中where一句中的ComName为字符型字段
请高人指点迷津

解决方案 »

  1.   

    comname = 'a2' 字符型数据要引起来!
      

  2.   

    stringl:='select * from component where comName=''a2''';
      

  3.   

    stringl:='select * from component where comName='''a2 +'''';
      

  4.   

    stringl:='select * from component where comName='+quotedstr('a2');
      

  5.   

    试过了,不好用
    错误提示是Missing operator or semicolon
    错误提示行为string1:='select * from Component where ComName='a2'';
      

  6.   

    string1:='select * from Component where ComName=''a2'''两个单引号
      

  7.   

    stringl:='select * from component where comName='''+ a2 +'''';
    是这样的  忘了加号了:)