Board index » delphi » Trying To copy data from TSQLCLIENTDAtaset to an array

Trying To copy data from TSQLCLIENTDAtaset to an array

Hi,

I am trying to copy the data from TSQLCLIENTDATASet to an dynamic array
and the print it into a file using string list. Here is the code. In my
report .txt I can see that it has loop through from the index number but
it seems like
NewDynamicArray[i, j] := Fields.Fields[j].asInteger; does not work and
did not copy the actual data into array.

So what to do ? any help ?

Soma

with AMarineSQLClientDataSet do begin
   CommandText:= 'Select * From Report';;
    if not Active then Open;
    First;
   NumberOfRecord:= RecordCount;
    NumberOfFields:= FieldCount;
    SetLength(NewDynamicArray, NumberOfRecord, NumberOfFields);
    For i:= 0 to NumberOfRecord -1 do begin
     For j:= 0 to NumberOfFields - 1  do begin
      NewDynamicArray[i, j] := Fields.Fields[j].asInteger;
        new.add(inttoStr( NewDynamicArray[i, j]));
      end;
      new.SaveToFile('D:\Development\report.txt');
    end;
    close;
  end;
  Result:= NewDynamicArray;

 

Re:Trying To copy data from TSQLCLIENTDAtaset to an array


Quote
In article <3D3705F5.1F522...@noaa.gov>, Soma Das wrote:
> I am trying to copy the data from TSQLCLIENTDATASet to an dynamic array
> and the print it into a file using string list. Here is the code. In my
> report .txt I can see that it has loop through from the index number but
> it seems like
> NewDynamicArray[i, j] := Fields.Fields[j].asInteger; does not work and
> did not copy the actual data into array.

> So what to do ? any help ?

You are missing a Next in your outer loop and overwrite the report.txt for
every round of the outer loop.

--
Peter Below (TeamB)  
Use the newsgroup archives :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be

Other Threads