ADOquery1.sql.Text:='select name form name where hykh="'+Edit2.text+'"';
 ADOquery1.execsql;每次执行这句就说:语法错误(操作符丢失)
这问题在哪呢?还有?怎么限定dbgrid单元格的宽度?

解决方案 »

  1.   

    ADOquery1.sql.Text:='select name form name where hykh='''+Edit2.text+'''';
    或者
    ADOquery1.sql.Text:='select name form name where hykh='+QuotedStr(Edit2.text);
    两单引号连写,在字符串中表示一个单引号.
      

  2.   

    //引号不对,有双引号
    ADOquery1.sql.Text:='select name form name where hykh="'+Edit2.text+'"'; 
    ADOquery1.execsql;
    -------------------------ADOquery1.sql.Text:=format('select name form name where hykh=''%s''',[Edit2.text]);
      

  3.   

    procedure TForm1.Button2Click(Sender: TObject);
    begin
      DBGrid1.Columns[0].Width:= 25;
    end;
      

  4.   

    ADOquery1.sql.Text:='select name form name where hykh="'+Edit2.text+'"';
    ADOquery1.open;
      

  5.   

    ADOquery1.sql.Text:='select name FROM name where hykh="'+Edit2.text+'"';
    //不是form
    ADOquery1.open;
    //对于查询,用open ;而update,insert用exesql;