Mega Code Archive

 
Categories / Delphi / ADO Database
 

Tablodan dosyaya aktarma

Codec By GeNiUS ! genius@turkiye.com Bir Ttable bileşeninin bağlı olduğu veri tabanı tablosundaki verilerin, Sabit kolon uzunluğunda veya, kolonlar arasına ayıraçlar koymak suretiyle metin dosyasına saklanması için geliştirilmiş bir Ttable türevi bileşene ait kod aşağıdadır. unit Exttab; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls,dialogs, Db, DBTables,StdCtrls,ComCtrls,WinTypes, WinProcs, ExtCtrls,DBCtrls; const LANGUAGE='TURKISH'; REGISTERED=FALSE; type TExtTab= class(Ttable) private { Private declarations } f_message:string; f_about:string; f_delimited:boolean; f_delimeter:string; f_filename:string; protected { Protected declarations } public { Public declarations } published procedure SaveToFile; property IsDelimited:boolean read f_delimited write f_delimited; property Delimeter:string read f_delimeter write f_delimeter; property FilePathAndName:string read f_filename write f_filename; property About:string read f_about write f_about; { Published declarations } end; implementation var msgid:integer; procedure TExtTab.SaveToFile; function tamamla(instr:string;x:integer;j:integer):string; var l,t:integer; begin if (IsDelimited) and (delimeter='') then delimeter:='@'; if not isdelimited then begin if length(fields[j].fieldname)>=x then x:=length(fields[j].fieldname); for l:=1 to x-length(instr) do instr:=instr+' '; result:=instr+' '; end else result:=instr+delimeter; end; var col_count:integer; row_count:integer; z,i,j:integer; row:string; f:system.text; st,et,ft:ttime; begin if not active then open; if FilePathAndName='' then begin filepathandname:= InputBox('Dikkat', 'Dosya ismini belirtiniz!', 'c:\TmpName.txt'); end; col_count:=fieldcount; row_count:=recordcount; rewrite(f,FilePathAndName); first; disablecontrols; st:=time; for j:=0 to col_count-1 do write(f,tamamla(fields[j].fieldname,fields[j].displaywidth,j)); writeln(f,''); for i:=0 to row_count-1 do begin for j:=0 to col_count-1 do begin if ord(fields[j].datatype)<14 then begin row:=tamamla(fields[j].asstring,fields[j].displaywidth,j); write(f,row); end; end; next; writeln(f,''); end; et:=time; ft:=et-st; showmessage('Başlangıç: '+timetostr(st)+' '+' Bitiş: '+timetostr(et)+''#10#13+ 'Kayıt Sayısı: '+inttostr(fieldcount)+' Kolon X '+inttostr(recordcount)+' Satır.'#10#13+ 'İşlem tamam!'); enablecontrols; closefile(f); end; end.