adoquery1.Close;
      adoquery1.SQL.Clear;
      adoquery1.SQL.Text:='select * from bjd where bjd1='+edit1.Text;
      adoquery1.Open;
用BDE加QUERY就沒問題一用ado就是這樣的了,怎麼都通不過這到底是什麼原因啊。

解决方案 »

  1.   

    adoquery1.Close;
    adoquery1.SQL.Clear;
    adoquery1.SQL.add('select * from bjd where bjd1='+edit1.Text);
    adoquery1.Open;
      

  2.   

    很不好意思blueshand(阿伟) 大哥。。我都用了無數次了都不行,
    他總是報invalid column name '03040501" (03040501是edit1.text的值)
      

  3.   

    改成下面的看看。我估计可能是数据类型的问题,不知道BJD1的类型是什么?      adoquery1.Close;
          adoquery1.SQL.Clear;
          adoquery1.SQL.Text:='select * from bjd where bjd1='''+edit1.Text+'''';
          adoquery1.Open;
      

  4.   

    数字类型直接写,文本类型要引号;
          adoquery1.Close;
          adoquery1.SQL.Clear;
          adoquery1.SQL.Text:='select * from bjd where bjd1='+QuotedStr(edit1.Text);
          adoquery1.Open;
      

  5.   

    adoquery1.SQL.Text:='select * from bjd where bjd1='+edit1.Text;
    这句错了,该为:
      adoquery1.SQL.Text:='select * from bjd where bjd1='+quoted(edit1.Text);
      

  6.   

    edit1.Text作为字段值应在前后加上引号,你设断点查一下adoquery1.sql.text的值就知道了。如果没有引号,就相当于bjdl=03040501,这样是判断字段值是否相等,当然就找不到这个字段了。
    adoquery1.SQL.add('select * from bjd where bjd1='+''''+edit1.Text+'''');
      

  7.   

    adoquery1.Close;
          adoquery1.SQL.Clear;
          adoquery1.SQL.Text:='select * from bjd where bjd1='''+edit1.Text+'''';
          adoquery1.Open;
      

  8.   

    各位提到的引號是單引號,還是雙引號,
    都不行,
    給果我改為
    tt:='select * from [bjd] where [bjd1]=:cc';
         adoquery1.Close;
          adoquery1.SQL.Clear;
          adoquery1.SQL.Text:=tt;
          adoquery1.Parameters.ParamByName('cc').Value:=edit1.Text;
    才OK!!!
      

  9.   

    我試了一下 SmallHand(火龍) 的可以運行。