Advertisement
Bensallam

save data

Nov 23rd, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 0.60 KB | None | 0 0
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. var
  3. BackUpFile : TextFile;
  4. i: Integer;
  5. cLine : string;
  6. begin
  7. AssignFile(BackUpFile, 'c:\BackUp.txt');
  8. Rewrite(BackUpFile);
  9. DBGrid1.DataSource.DataSet.First;
  10.  
  11. while not DBGrid1.DataSource.DataSet.Eof do
  12. begin
  13. cLine := '';
  14. for i := 0 to DBGrid1.FieldCount - 1 do
  15. begin
  16. cLine := cLine+DBgrid1.fields[i].asString+' ';
  17. end;
  18. WriteLn(BackUpFile, cLine);
  19. DBGrid1.DataSource.DataSet.Next;
  20. end;
  21.  
  22. CloseFile(BackUpFile);
  23. end;
  24.  
  25. Now this text file is like that:
  26. 123
  27. abc
  28. 567
  29. stu
  30. [and so on]
  31.  
  32. But I want it like that:
  33. 123 abc
  34. 567 stu
  35. [and so on]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement