1

I have Delphi application that connected to SQL server using ADODB component like (TAdoQuery , TADOStoredProcedure , TADOConnection .....) Now am trying to migrating from ADODB Connection to FireDac in delphi 10.3 Rio , but how I can passing Recordset from TFDQuery to TFDStoredProcedure like this :

enter code here
var
  Qry: TAdoQuery;
  List: TADOStoredProc;
  i: Integer;
  Item: TCurrencyVal;
begin
  Qry := TAdoQuery.Create(nil);
  Qry.Connection := Connection;
  Qry.SQL.Add('SELECT * FROM Currency WHERE ID=' + IntToStr(ID));
  Qry.SQL.Add('SELECT * FROM CurrencyValues WHERE CurrencyID=' + IntToStr(ID));
  Qry.Open;
  Result := nil;

  if Qry.RecordCount = 1 then
  begin
    Result := TCurrency.Create(AOwner);

    TCurrency(Result).ID := ID;
    TCurrency(Result).FCode := Qry.FieldByName('Code').AsString;
    TCurrency(Result).FName := Qry.FieldByName('Name').AsString;
    TCurrency(Result).FDefaultPrice := Qry.FieldByName('DefaultPrice').AsFloat;
    TCurrency(Result).FDefaultCurrency := Qry.FieldByName('DefaultCurrency')
      .AsBoolean;
    TCurrency(Result).FPartName := Qry.FieldByName('PartName').AsString;
    TCurrency(Result).FDecimalDigits := Qry.FieldByName('DecimalDigits')
      .AsInteger;
    TCurrency(Result).FAccountID := Qry.FieldByName('AccountID').AsInteger;
    TCurrency(Result).FMajorGender := Qry.FieldByName('MajorGender').AsInteger;;
    TCurrency(Result).FPluralMajor := Qry.FieldByName('PluralMajor').AsString;
    TCurrency(Result).FMinorGender := Qry.FieldByName('MinorGender').AsInteger;;
    TCurrency(Result).FPluralMinor := Qry.FieldByName('PluralMinor').AsString;
    TCurrency(Result).FFracsInUnit := Qry.FieldByName('FracsInUnit').AsInteger;;
    TCurrency(Result).FCountryName := Qry.FieldByName('CountryName').AsString;

    List := TADOStoredProc.Create(Result);
    List.Recordset := Qry.NextRecordset(i);

    for i := 0 to List.RecordCount - 1 do
    begin
      List.RecNo := i + 1;

      Item := TCurrencyVal.Create(Result);
      Item.ID := List.FieldByName('ID').AsInteger;
      Item.Date := List.FieldByName('Date').AsDateTime;
      Item.SellPrice := List.FieldByName('Value').AsFloat;

      TCurrency(Result).AddItem(Item);
    end;

    List.Close;
    List.Free;
  end;
mamon
  • 11
  • 4
  • I don't understand your code. You never execute the stored procedure. Would explain what it is supposed to do? Would you also show complete code? – fpiette Dec 06 '20 at 18:28
  • I don't understand at all what this code is supposed to do. Why do you think assigning `Result` (whatever that is) as the owner of a new `TADOStoredProcedure` will do? And why would you expect doing so would execute that stored procedure? – Ken White Dec 07 '20 at 00:10
  • I don't need stored procedure but i need another component to receive the second recordset and read data from it code worked correctly with ado component but when I change it to FireDac it doesn't work because there isn't property with name recordset in component finally i found tfdmemtable that do this thing with data property thenk you – mamon Dec 07 '20 at 19:49

0 Answers0