请看我的代码,为什么老是提示说没定义ParamByName
我在uses 里已经引用了adodb的;procedure Tcjcx_fr.mh_btClick(Sender: TObject);
var s:string;
begin
with stuxinxi_Dm do
begin
  s:=quotedstr(trim(gjz_ed.text));
  adoquery1.Close;
  adoquery1.SQL.Clear;
  case mhtj_rg.ItemIndex of
  //0:按姓名搜索;1:按课程名搜索  0:adoquery1.SQL.Add('Select * From  chengjibiao where stu_no in(select stu_no from xuejibiao where stu_name Like :str');
    //分姓名的3种输入情况搜索成绩表
    if LeftStr(s,1)<>'' then
    ADOQuery1.SQL.ParamByName('str').AsString:=s+'%' //左匹配
      else if RightStr(s,1)<>'' then
        ADOQuery1.SQL.ParamByName('str').AsString:='%'+s //右匹配
        else
          ADOQuery1.SQL.ParamByName('str').AsString:='%'+s+'%';  //中间匹配  1:adoquery1.SQL.Add('Select * From  chengjibiao where kecheng_no in(select kecheng_no from kechengbiao where kecheng_name Like :str');
    //分课程名的3种输入情况搜索成绩表
    if LeftStr(s,1)<>'' then
    ADOQuery1.SQL.ParamByName('str').AsString:=s+'%'  //左匹配
      else if RightStr(s,1)<>'' then
        ADOQuery1.SQL.ParamByName('str').AsString:='%'+s //右匹配
        else
          ADOQuery1.SQL.ParamByName('str').AsString:='%'+s+'%'; //中间匹配  end;
  ADOQuery1.Prepared;
  ADOQuery1.Open ;end;
end;

解决方案 »

  1.   

    顶一下,ADOQuery1.Prepared;//做什么的?
      

  2.   


    procedure TForm2.FlatEdit1KeyPress(Sender: TObject; var Key: Char);
    begin
        if key=#13 then
           begin
           if flatedit1.Text='' then
           application.MessageBox('您没有输入关键字!','给您的提示',mb_ok+MB_ICONEXCLAMATION )
           else
           adoquery1.Close;
           adoquery1.SQL.Clear;
           adoquery1.SQL.Add('select * from 内容 where 内容 like :aa');
           adoquery1.Parameters.ParamByName('aa').Value:='%'+flatedit1.Text+'%';
           adoquery1.Open;
           showmessage('找到满足条件的记录数:  '+inttostr(adoquery1.RecordCount)+'条');
           flatedit1.Text:='';
           end;
    end;
      

  3.   

    Var
        NameStr:String;∥设置字符串中间变量
        Begin
        NameStr:=′王′;
        Query1SQLClear{清除SQL属性中的SQL命令语句}
        Query1SQLAdd(′Select*FromCustomdbwhere(Name1&gt;=N1)and(Name2&lt;=N2)′);∥SQL命令语句
        Query1params[0]AsString:=NameStr+chr(0);∥控制参数在NameStr+Chr(0)
        Query1params[1]AsString:=NameStr+chr($ff);∥和NameStr+Chr($ff)之间
        Query1Open;∥打开数据库,执行SQL查询
        End;
      

  4.   

    ADOQuery1.SQL.ParamByName('str')
    这样不对
    ADOQuery1.fieldByName('str')
      

  5.   

    to  web700(*FS*的小狗腿子)
    你认为我的if语句对吗?你的还只是我其中的一种情况吧。
      

  6.   

    还想请教一下
    我的case语句都没执行,是否是因为我把radiogroup组件放在了groupbox里呢
      

  7.   

    请再给指导一下,为什么表zhuanyemb的字段zhuanye_no是无效的呢?
    procedure Tcjcx_fr.zhtj_btClick(Sender: TObject);
    begin
    with stuxinxi_Dm do
    begin
      ADOQuery1.Close;
      ADOQuery1.SQL.Clear;
      adoquery1.SQL.Add('select  t_cj.*, stu_name,zhuanye_name,kecheng_name');
      adoquery1.SQL.Add('from chengjibiao t_cj,xuejibiao t_xj,zhuanyemb t_zy,kechengbiao t_kc');
      adoquery1.SQL.Add('where t_cj.stu_no=t_xj.stu_no and t_xj.stu_name like :str1');
      ADOQuery1.Parameters.ParamByName('str1').value:='%'+xm_ed.Text+'%';
      adoquery1.SQL.Add('and t_cj.kecheng_no=t_kc.kecheng_no and t_kc.kecheng_name like :str2');
      ADOQuery1.Parameters.ParamByName('str2').value:='%'+kcm_cb.Text+'%';
      adoquery1.SQL.Add('and t_zy.zhuanye_no=t_kc.zhuanye_no and t_zy.zhuanye_name like :str3');
      ADOQuery1.Parameters.ParamByName('str3').value:='%'+zy_cb.Text+'%';
      ADOQuery1.Prepared;
      try
      ADOQuery1.Open;
      except
      ADOQuery1.ExecSQL;
      end;
    end;
    end;