运行以下代码:   strStyle := '' ;
   strText := '' ;      strStyle := ComboBox1.text ;
   strText := Trim(Edit1.text) ;   AdoQuery1.Close ;
   //ADOQuery1.Prepared := True ;
   ADOQuery1.SQL.Clear ;
   ADOQuery1.SQL.Add('select * from book where strStyle=:strText') ;   //*****
   ADOQuery1.Parameters.ParamByName('strStyle').value:=strStyle ;
   ADOQuery1.Open ;报错:“ ADOQuery1 : Parameter 'strStyle' not found ”在执行到  ***** 处时,我把鼠标置于 SQL  上,显示的为:“ ADOQuery1.SQL =() ”,
这是什么原因?

解决方案 »

  1.   

    ADOQuery1.Parameters.ParamByName('strStyle').Value 改成
    ADOQuery1.Parameters.ParamByName('strText').Value
      

  2.   

    参数是指冒号(:)后面的,如上应该是 strText,不是strStyle;
      

  3.   

    ADOQuery1.Parameters.ParamByName('strText').Value应该是strText
      

  4.   

    哈哈,
    ADOQuery1.SQL.Add('select * from book where 
           strStyle=:strText') ;   
    ADOQuery1.Parameters.ParamByName('strStyle').value:=strStyle ;
    应该改成:
    ADOQuery1.Parameters.ParamByName('strText').value:=strStyle ;
      

  5.   

    ADOQuery1.Parameters.ParamByName('strStyle').value:=strStyle ;改成
    ADOQuery1.Parameters.ParamValues('strStyle').value:=strStyle ;
      

  6.   

    to : lincanwen(密码错误) and bluemeteor按你们的提示,却报错: ORA-00904: 非法的列名
      

  7.   

    ADOQuery1.Parameters.ParamByName('strText').Value
    且ADOQuery1.Parameters中参数名称应为strText
      

  8.   

    在你的ADOQuery图标上单击右键,选Fields Editor,再在弹出的窗口中单击
    右键,选Add All Fields。
      

  9.   

    却报错: ORA-00904: 非法的列名?
    你的数据库有strStyle这个字段吗?
      

  10.   

    ADOQuery1.SQL.Add('select * from book where strStyle=:strText')改成
    ADOQuery1.SQL.Add('select * from book where ‘+strStyle+‘=:strText')
      

  11.   

    你的数据库可能没有strStyle字段吧
      

  12.   

    對這樣做不好
    而且你根本就沒有定義strStyle;strText這兩個為局部變量;
    你應該在begin上面用var來定義;
    還有你的數據庫里面可能沒有strstyle和strtext這兩個字段吧
    where 后面應該跟的是field1=:fieldNew1 and field2=:fieldNew2
    然后再用adoquery1.Parameters.ParamByName('fieldNew1').asstring:=combobox1.text;  
      

  13.   

    我的数据库上是无strStyle字段,但在执行查询前有以下语句: strStyle := 'bookname' ;
    且在执行时 strStyle 以被赋值为 bookname
    我的数据库上是有 bookname 字段
      

  14.   

    最后几条语句这样写
    ADOQuery1.SQL.Clear ;
    ADOQuery1.SQL.Add('select * from book where '+strstyle+'='+''''+strtext+'''');
    ADOQuery1.Open ;
      

  15.   

    或者这样
    ADOQuery1.SQL.Clear ;
    ADOQuery1.SQL.Add('select * from book where '+ strStyle+'=:strText') ; 
    ADOQuery1.Parameters.ParamByName('strtext').value:=strtext ;   
    ADOQuery1.Open ;
      

  16.   

    AdoQuery1.Close ;
       //ADOQuery1.Prepared := True ;
       ADOQuery1.SQL.Clear ;
       ADOQuery1.SQL.Add('select * from book where strStyle=:strText') ;   //*****
       ADOQuery1.Parameters.ParamByName('strStyle').datatype:=ftstring ;
       ADOQuery1.Parameters.ParamByName('strStyle').value:=strStyle ;
       ADOQuery1.Open ;
      

  17.   

    对不起,应该是:
       AdoQuery1.Close ;
       ADOQuery1.SQL.Clear ;
       ADOQuery1.SQL.Add('select * from book where strStyle=:strStyle') ;   //*****
       ADOQuery1.Parameters.ParamByName('strStyle').datatype:=ftstring ;
       ADOQuery1.Parameters.ParamByName('strStyle').value:=strStyle ;
       ADOQuery1.Open ;