View Single Post
 
Old 02-16-2017, 05:46 PM
FreakaZoid2 FreakaZoid2 is offline
Senior Member
 
Join Date: Jul 2009
Posts: 294
Default discovered the OOM error was due to ODBC driver

apparently had to get a new ole db provider and use ADO

Will close issue thanks for all the info have rewritten code based upon another article i found:
Code:
procedure TForm3.Button2Click(Sender: TObject);
var
  fld : TField;
  _tbl : TStringlist;
  _afile  : TStreamWriter;
  I: Integer;
begin
  if not(ADOQuery1.Active) then
    ADOQuery1.Active := True;
  _afile := TStreamWriter.Create('t:\dbf\ar012.csv', false, TEncoding.UTF8);
  _afile.AutoFlush := True;
  _afile.NewLine := sLineBreak;
  _tbl := TStringlist.Create;
  _tbl.Clear;
  _tbl.QuoteChar := '"';
  _tbl.Delimiter := ';';
  ADOQuery1.GetFieldNames(_tbl);
  _afile.WriteLine(_tbl.DelimitedText);
  ADOQuery1.First;
  while not(ADOQuery1.Eof) do
  begin
    _tbl.Clear;
    for fld in ADOQuery1.Fields do
      _tbl.Add(fld.Text);
    _afile.WriteLine(_tbl.DelimitedText);
    ADOQuery1.Next;
  end;
  FreeAndNil(_tbl);
  _afile.Free;
end;