Adocn:=TADOConnection.Create(self);
  Adocn.ConnectionString:='Provider=SQLOLEDB.1;Persist Security Info=True;'+
        'User ID=sa;Workstation ID=PERL;Initial Catalog=F6;Use Procedure for Prepare=1;Auto Translate=True;'+
        'Packet Size=4096;Data Source=cw3';
  Adocn.LoginPrompt:=false;
  Adocn.KeepConnection:=true;
  showmessage(adocn.ConnectionString);
  Adocn.open;
  adostor:=tadostoredproc.create(self);
  adostor.Connection:=adocn;
  adostor.Close;
  adostor.ProcedureName:= 'sp_f_rptqry1';
  adostor.Parameters.ParamByName('@c_id').Value:='01';
  adostor.Prepared:= true;
  adostor.Open;
  edit1.Text:=adostor.fields[0].asstring;为何报错说找不到参数‘@c_id’,不解,请各位前辈赐教;

解决方案 »

  1.   

    可以用ADOSTOR。PARAMETERS[1].VALUE:='01';
    试试
      

  2.   

    确定'sp_f_rptqry1'里有‘@c_id’参数吗?
      

  3.   

    adostor:=tadostoredproc.create(self);
    你是动态生成的 肯定没有
      

  4.   

    adostor.Params.Clear;
        adostor.Param.Create('@c_id',.. ptInput);
      

  5.   

    self.ADOStoredProc1.Parameters.CreateParameter('@tablename',ftstring,pdinput,14,null);
    self.ADOStoredProc1.Parameters.CreateParameter('@result',ftstring,pdoutput,20,null);
      

  6.   

    adostor.ProcedureName:= 'sp_f_rptqry1';后加入
    with adostor.Parameters.AddParameter do
        begin
          Name:='@c_id';
          Attributes:=[paNullable];
          DataType:=ftString;
          Size:=12;
        end;
      

  7.   

    多谢Hank前辈,我是个新手,加入后果然奏效,但我还有疑问,Attributes代表什么,DataType为何用ftstring,而不是string,谢谢