매일생성되는 화일에서 정리에서 리포트로 뽑으려 하는데
잘 정리가 않되서요 그리고 델파이로 잔것이 실행도 않되고요
도와주세여,,
unit packet;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Grids, DBGrids, Db, DBTables;
type
TForm1 = class(TForm)
DataSource1: TDataSource;
Label1: TLabel;
Table1: TTable;
Label2: TLabel;
DBGrid1: TDBGrid;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
f : textfile;
S : string;
nloop : Longint;
begin
nloop :=0;
Assignfile(f,'c:ab199904.txt');
while not seekEof(f) do
begin
readln(S);
// if (ORD(S[1]) = 13 and ORD(S[2]) = 10) then
// begin
// Table1.Append;
//공백레코드 추가
// nloop := 0;
// end
// else
// begin
Table1.edit;
Table1.Fields[nloop].AsString := s;
Table1.Post;
inc(nloop);
end;
end;
end.
> 매일생성되는 화일에서 정리에서 리포트로 뽑으려 하는데
> 잘 정리가 않되서요 그리고 델파이로 잔것이 실행도 않되고요
> 도와주세여,,
>
>
> unit packet;
>
> interface
>
> uses
> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
> StdCtrls, Grids, DBGrids, Db, DBTables;
>
> type
> TForm1 = class(TForm)
> DataSource1: TDataSource;
> Label1: TLabel;
> Table1: TTable;
> Label2: TLabel;
> DBGrid1: TDBGrid;
> Button1: TButton;
> procedure Button1Click(Sender: TObject);
> private
> { Private declarations }
> public
> { Public declarations }
> end;
>
> var
> Form1: TForm1;
>
> implementation
>
> {$R *.DFM}
>
> procedure TForm1.Button1Click(Sender: TObject);
> var
> f : textfile;
> S : string;
> nloop : Longint;
> begin
> nloop :=0;
> Assignfile(f,'c:ab199904.txt');
>
> while not seekEof(f) do
>
> begin
> readln(S);
>
> // if (ORD(S[1]) = 13 and ORD(S[2]) = 10) then
> // begin
> // Table1.Append;
> //공백레코드 추가
> // nloop := 0;
> // end
> // else
> // begin
> Table1.edit;
> Table1.Fields[nloop].AsString := s;
> Table1.Post;
> inc(nloop);
> end;
> end;
> end.
레코드 형으로 정의를 해서 사용하시는것이 좀 편할 꺼 같군요
type
// 레코드의 구조(텍스트파일의 레코드구조가 테이블과 구조가 같아야 겠죠)
str_R = Record
s_code : string[4];
s_name : string[12];
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
F: TextFile;
S: str_R;
begin
if OpenDialog1.Execute then { Display Open dialog box }
begin
AssignFile(F, OpenDialog1.FileName); { File selected in dialog box }
Reset(F);
while not EOF(F) do begin
Read(F, S.s_code);
Readln(F, S.s_name);
// 디비 핸들링 필드에 넣어주고 포스트하고하는 작업들....쩝
end;
CloseFile(F);
end;
end;