unit Unit3;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, DBCtrls, Grids, DBGrids, StdCtrls, DB, ADODB, DBTables;type
TForm3 = class(TForm)
Button1: TButton;
Session1: TSession;
Database1: TDatabase;
Table1: TTable;
Memo1: TMemo;
Label1: TLabel;
private
{ Private declarations }
public
{ Public declarations }
end; procedure getdata(ncount:integer;s:string);var
Form3: TForm3;implementation{$R *.dfm}type
TtableThread = class(TThread)
private
Ftable:ttable;
FtableException: Exception;
procedure tableError;protected
procedure Execute; override;
public
constructor Create(t: Ttable); virtual;end;constructor TtableThread.Create(t: Ttable);
begin
inherited Create(True); // create suspended thread
Ftable := t; // set parameters
FreeOnTerminate := True;
Resume; // thread that puppy!
end;procedure TtableThread.Execute;
begin
try except
FtableException := ExceptObject as Exception;
Synchronize(tableError); // show exception from main thread
end;
end;
procedure TtableThread.tableError;
begin
Application.ShowException(ftableException);
end;//---------以下为取得数据插入到数据库,是关键,里面的判断出错还需要根据条件----------
//---------变化更改,对于警告值需要改,看使用情况-------------------------procedure getdata(ncount:integer;s:string);var
i,insertsecond:integer;
Hour, Minute, Second, sSecond : word;
begin
with form3 do with table1 do begin
TtableThread.Create(table1);
active:=true;
last;
for i := 0 to nCount-1 do
begin
insert; fieldbyname('time').Value:= formatdatetime('hh:nn:ss',now); DecodeTime( now, Hour, Minute, Second, sSecond );
insertsecond:=hour*3600+minute*60+second;
fieldbyname('second').Value:=insertsecond; FieldByName('cs_id').value := Copy(s,i*26+1,11); begin
if (copy(s,i*26+13,7)=' -- ') or (copy(s,i*26+13,7)=' ') or (copy(s,i*26+13,7)=', --')or (copy(s,i*26+13,7)=', 0.00') then
FieldByname('tb').Value :=0
else
FieldByname('tb').AsString := copy(s,i*26+13,7);
end;
begin
if ((Copy(s,i*26+21,4)=' --') or (Copy(s,i*26+21,4)=' -- ')or (Copy(s,i*26+21,4)=' >85')) then
FieldByname('cq').Value :=0
else
FieldByname('cq').AsString := Copy(s,i*26+21,4);
end;
end;
post;
end;
end;
end.
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, DBCtrls, Grids, DBGrids, StdCtrls, DB, ADODB, DBTables;type
TForm3 = class(TForm)
Button1: TButton;
Session1: TSession;
Database1: TDatabase;
Table1: TTable;
Memo1: TMemo;
Label1: TLabel;
private
{ Private declarations }
public
{ Public declarations }
end; procedure getdata(ncount:integer;s:string);var
Form3: TForm3;implementation{$R *.dfm}type
TtableThread = class(TThread)
private
Ftable:ttable;
FtableException: Exception;
procedure tableError;protected
procedure Execute; override;
public
constructor Create(t: Ttable); virtual;end;constructor TtableThread.Create(t: Ttable);
begin
inherited Create(True); // create suspended thread
Ftable := t; // set parameters
FreeOnTerminate := True;
Resume; // thread that puppy!
end;procedure TtableThread.Execute;
begin
try except
FtableException := ExceptObject as Exception;
Synchronize(tableError); // show exception from main thread
end;
end;
procedure TtableThread.tableError;
begin
Application.ShowException(ftableException);
end;//---------以下为取得数据插入到数据库,是关键,里面的判断出错还需要根据条件----------
//---------变化更改,对于警告值需要改,看使用情况-------------------------procedure getdata(ncount:integer;s:string);var
i,insertsecond:integer;
Hour, Minute, Second, sSecond : word;
begin
with form3 do with table1 do begin
TtableThread.Create(table1);
active:=true;
last;
for i := 0 to nCount-1 do
begin
insert; fieldbyname('time').Value:= formatdatetime('hh:nn:ss',now); DecodeTime( now, Hour, Minute, Second, sSecond );
insertsecond:=hour*3600+minute*60+second;
fieldbyname('second').Value:=insertsecond; FieldByName('cs_id').value := Copy(s,i*26+1,11); begin
if (copy(s,i*26+13,7)=' -- ') or (copy(s,i*26+13,7)=' ') or (copy(s,i*26+13,7)=', --')or (copy(s,i*26+13,7)=', 0.00') then
FieldByname('tb').Value :=0
else
FieldByname('tb').AsString := copy(s,i*26+13,7);
end;
begin
if ((Copy(s,i*26+21,4)=' --') or (Copy(s,i*26+21,4)=' -- ')or (Copy(s,i*26+21,4)=' >85')) then
FieldByname('cq').Value :=0
else
FieldByname('cq').AsString := Copy(s,i*26+21,4);
end;
end;
post;
end;
end;
end.
解决方案 »
- IdTCPServer同时向多个Client发送不同文件?
- 如何把虚拟键码如何转换成字符串?
- 求救Grid index out of range错误!!!
- 关于控件的安装
- ehlib中的datagrideh的ondrawcolumncell出错,原因何在??
- 如何读取TWebBrowser状态(Status Code)
- 出差前把老婆教訓了一頓...
- 关于搜索内存地址的问题........
- 关于二为数组的问题,请教!
- 求Epson TMu300a打印机的指令集(中文&例程),300分相送!
- label问题
- ExpressPrinting System Suite怎么这么水,一进入打印预览,所有的数据就没了???
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, DBCtrls, Grids, DBGrids, StdCtrls, DB, ADODB, DBTables;type
TForm3 = class(TForm)
Button1: TButton;
Session1: TSession;
Database1: TDatabase;
Table1: TTable;
Memo1: TMemo;
Label1: TLabel;
private
{ Private declarations }
public
{ Public declarations }
end; procedure getdata(ncount:integer;s:string);var
Form3: TForm3;implementation{$R *.dfm}type
TtableThread = class(TThread)
private
Ftable:ttable;
FtableException: Exception;
procedure tableError;protected
procedure Execute; override;
public
constructor Create(t: Ttable); virtual;end;constructor TtableThread.Create(t: Ttable);
begin
inherited Create(True); // create suspended thread
Ftable := t; // set parameters
FreeOnTerminate := True;
Resume; // thread that puppy!
end;procedure TtableThread.Execute;
begin
try except
FtableException := ExceptObject as Exception;
Synchronize(tableError); // show exception from main thread
end;
end;
procedure TtableThread.tableError;
begin
Application.ShowException(ftableException);
end;//---------以下为取得数据插入到数据库,是关键,里面的判断出错还需要根据条件----------
//---------变化更改,对于警告值需要改,看使用情况-------------------------procedure getdata(ncount:integer;s:string);var
i,insertsecond:integer;
Hour, Minute, Second, sSecond : word;
begin
with form3 do with table1 do begin
TtableThread.Create(table1);
active:=true;
last;
for i := 0 to nCount-1 do
begin
insert; fieldbyname('time').Value:= formatdatetime('hh:nn:ss',now); DecodeTime( now, Hour, Minute, Second, sSecond );
insertsecond:=hour*3600+minute*60+second;
fieldbyname('second').Value:=insertsecond; FieldByName('cs_id').value := Copy(s,i*26+1,11); begin
if (copy(s,i*26+13,7)=' -- ') or (copy(s,i*26+13,7)=' ') or (copy(s,i*26+13,7)=', --')or (copy(s,i*26+13,7)=', 0.00') then
FieldByname('tb').Value :=0
else
FieldByname('tb').AsString := copy(s,i*26+13,7);
end;
begin
if ((Copy(s,i*26+21,4)=' --') or (Copy(s,i*26+21,4)=' -- ')or (Copy(s,i*26+21,4)=' >85')) then
FieldByname('cq').Value :=0
else
FieldByname('cq').AsString := Copy(s,i*26+21,4);
end;
end;
post;
end;
end;
end.
主要程序如下,
with table1 do begin
TtableThread.Create(table1);
active:=true;
last;
for i := 0 to nCount-1 do
begin
insert; fieldbyname('time').Value:= formatdatetime('hh:nn:ss',now); FieldByname('cq').AsString := Copy(s,i*26+21,4);
FieldByname('tb').AsString := copy(s,i*26+13,7);
FieldByname('cq').AsString := Copy(s,i*26+21,4); post;
这四个列是ACCESS里的一张表,上面程序多了写其他的条件判断,不过主要实现
还是这几条,关键是我的线程使用是否有错,我的速度不够快,要等待,出现SQL等待
一下,你的线程不用改
因为TClientDataSet把数据能放在内存里,你可以用它的loadfromfile功能
就不用写代码写什么内存了,
其它的地方不用改
我的MAIL,[email protected]
再有问题MAIL吧
我们公司上回是,实时写库是5分种,后来后内存不到1分钟了
你用我那个办法,可能效果没那么好,
如果FILE不行,
你再试试别的方法一个问题两个分,
太谢谢了,
呵呵,我已经一个月没有挣一点分了
我们公司上回是,实时写库是5分种,后来后内存不到1分钟了
你用我那个办法,可能效果没那么好,
如果FILE不行,
你再试试别的方法一个问题两个分,
太谢谢了,
呵呵,我已经一个月没有挣一点分了