Migration From Ado To Sdac

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
ariopax
Posts: 1
Joined: Sun 13 Feb 2022 05:50

Migration From Ado To Sdac

Post by ariopax » Sun 13 Feb 2022 06:27

Hi

I decided to migration from ADO to SDAC.
I download Trial and Install it on Delphi 10.4.2.
I encountered the following problems and did not find a solution
I have used the following commands in my program code.


1- TMSSQL.SetLength(KFields, all);
2- String1 := TMSSQL.FieldByName('FName').AsString;
3- TMSSQL.FieldCount
4- TMSSQL.Reccount
5- TMSSQL.DesignerData

I searched the forum, but did not find what I was looking for.
Where can I find the answers to my problems?

Regards.

paweld
Posts: 19
Joined: Mon 29 Sep 2014 08:56

Re: Migration From Ado To Sdac

Post by paweld » Mon 14 Feb 2022 09:15

TMSSQL does not return any records, so you cannot retrieve the data.
Use a TMSQuery component for this purpose, e.g.

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
var
  MSQuery1: TMSQuery;
  i: Integer;
begin
  MSQuery1 := TMSQuery.Create(nil);
  MSQuery1.Connection := MSConnection1;
  MSQuery1.SQL.Text := ' select * from table order by id ';
  MSQuery1.Open;
  Memo1.Lines.Add('Records count: ' + IntToStr(MSQuery1.RecordCount));
  if not MSQuery1.IsEmpty then
  begin
    MSQuery1.First;
    while not MSQuery1.EOF do
    begin
      Memo1.Lines.Add('Record no: ' + IntToStr(i));
      for i := 0 to MSQuery1.FieldCount - 1 do
        Memo1.Lines.Add(MSQuery1.Fields[i].FieldName + ': ' + MSQuery1.Fields[i].AsString);  //or: MSQuery1.FieldByName(MSQuery1.Fields[i].FieldName).AsString
      MSQuery1.Next;
    end;
  end;
  MSQuery1.Close;
end;

Post Reply