在sql server中编写一个存储过程,返回一个数据集,
在delphi中则么得到这个存储过程的返回值个数和所有返回值?

解决方案 »

  1.   

    在存储过程中使用参数create procedure ***
    (
      @count int output
     )
    as
      select @count=count(*) from table_name;
      

  2.   

    存储过程都写好了,没有问题,关键是在delphi的客户端怎么用,
    使用StoredProc,可以得到所有的返回信息吗?我说的返回信息有很多条记录!
      

  3.   

    with (TStoredProc.Create(nil))do
        begin
          try
            DatabaseName := 'DBName';
            StoredProcName := 'ProcName';        Params.CreateParam(ftString,'@Param',ptInput);
        
            Params.ParamByName('@Param').AsString := '123';
            
            Prepare;
            Active := True;
            if RecordCount<>0 then
              ParamByName('@Param').AsString; //返回值
          finally
            if Active then active:=False;
            Free;
          end;//try
      

  4.   

    with TStoredProc.Create(nil) do
      begin
        try
          DatabaseName := 'PdyuDB';
          StoredProcName := 'GetAll';      Params.CreateParam(ftInteger, '@ID', ptInput);
          Params.ParamByName('@ID').AsInteger := 1;      Prepare;
          Active := True;
          if RecordCount <> 0 then
          begin
            while not Eof do
            begin
              nID := FieldByName('ProductID').AsInteger;//返回数据集的字段
              strName := FieldByName('ProductName').AsString;
              nPrice := FieldByName('Price').AsInteger;
              Next;
            end;
          end;
        finally
          if Active then Active := False;
          Free;
        end;