隐
隐儿
Unregistered / Unconfirmed
GUEST, unregistred user!
我运行下面代码,循环70多次后出现下面的错误,哪位大侠帮我:
Operation not applicable
Too many open tables
Table:c:/zjy/ration_framer.db
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Menus, Db, DBTables;
type
TForm1 = class(TForm)
Table1: TTable;
Table2: TTable;
Table3: TTable;
MainMenu1: TMainMenu;
N1: TMenuItem;
procedure N1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.N1Click(Sender: TObject);
var
temp1,temp2,temp3,temp4:string;
rgf,clf,jxf,zjfouble;
query1,query2:Tquery;
begin
table1.First;
while not table1.Eof do
begin
rgf:=0;
clf:=0;
jxf:=0;
zjf:=0;
temp1:=table1.fieldbyname('code').asstring;
query1:=tquery.Create(nil);
// query1.Database:='c:/zjy';
query1.Close;
query1.SQL.Clear;
query1.SQL.Add('select * from ration_framer where code='''+temp1+'''');
query1.ExecSQL;
query1.Open;
query1.First;
while not query1.Eof do
begin
temp2:=query1.FieldByName('material_code').asstring;
if Pos('-',temp2)>0 then
begin
temp3:=query1.FieldByName('material_code').asstring;
query2:=tquery.Create(nil);
// query2.Database:='c:/zjy';
query2.Close;
query2.SQL.Clear;
query2.SQL.Add('select * from ration_framer where code='''+temp3+'''');
query2.ExecSQL;
query2.Open;
query2.First;
while not query2.Eof do
begin
temp4:=query2.fieldbyname('material_code').asstring;
if table3.FindKey(['',temp4]) then
begin
if table3.FieldByName('mark').asstring='RG' then
begin
rgf:=rgf+table3.fieldbyname('price1').asfloat*query2.fieldbyname('content').asfloat*query1.fieldbyname('content').asfloat;
end else
if (table3.FieldByName('mark').asstring='CL') or (table3.FieldByName('mark').asstring='CB') then
begin
clf:=clf+table3.fieldbyname('price1').asfloat*query2.fieldbyname('content').asfloat*query1.fieldbyname('content').asfloat;
end else
if table3.FieldByName('mark').asstring='JX' then
begin
jxf:=jxf+table3.fieldbyname('price1').asfloat*query2.fieldbyname('content').asfloat*query1.fieldbyname('content').asfloat;
end;
end;
query2.Next;
end;
query2.Close;
query2.Free;
query1.Next;
end else
begin
temp4:=query1.fieldbyname('material_code').asstring;
if table3.FindKey(['',temp4]) then
begin
if table3.FieldByName('mark').asstring='RG' then
begin
rgf:=rgf+table3.fieldbyname('price1').asfloat*query1.fieldbyname('content').asfloat;
end else
if (table3.FieldByName('mark').asstring='CL') or (table3.FieldByName('mark').asstring='CB') then
begin
clf:=clf+table3.fieldbyname('price1').asfloat*query1.fieldbyname('content').asfloat;
end else
if table3.FieldByName('mark').asstring='JX' then
begin
jxf:=jxf+table3.fieldbyname('price1').asfloat*query1.fieldbyname('content').asfloat;
end;
query1.Next;
end;
end;
end;
query1.Close;
query1.Free;
table1.Edit;
table1.FieldByName('fee').asfloat:=rgf+clf+jxf;
table1.Post;
table1.Next;
table1.Edit;
table1.FieldByName('fee').asfloat:=rgf;
table1.Post;
table1.Next;
table1.Edit;
table1.FieldByName('fee').asfloat:=clf;
table1.Post;
table1.Next;
table1.Edit;
table1.FieldByName('fee').asfloat:=jxf;
table1.Post;
table1.Next;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
table1.Open;
table2.Open;
table3.Open;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
table1.close;
table2.close;
table3.close;
end;
end.
Operation not applicable
Too many open tables
Table:c:/zjy/ration_framer.db
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Menus, Db, DBTables;
type
TForm1 = class(TForm)
Table1: TTable;
Table2: TTable;
Table3: TTable;
MainMenu1: TMainMenu;
N1: TMenuItem;
procedure N1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.N1Click(Sender: TObject);
var
temp1,temp2,temp3,temp4:string;
rgf,clf,jxf,zjfouble;
query1,query2:Tquery;
begin
table1.First;
while not table1.Eof do
begin
rgf:=0;
clf:=0;
jxf:=0;
zjf:=0;
temp1:=table1.fieldbyname('code').asstring;
query1:=tquery.Create(nil);
// query1.Database:='c:/zjy';
query1.Close;
query1.SQL.Clear;
query1.SQL.Add('select * from ration_framer where code='''+temp1+'''');
query1.ExecSQL;
query1.Open;
query1.First;
while not query1.Eof do
begin
temp2:=query1.FieldByName('material_code').asstring;
if Pos('-',temp2)>0 then
begin
temp3:=query1.FieldByName('material_code').asstring;
query2:=tquery.Create(nil);
// query2.Database:='c:/zjy';
query2.Close;
query2.SQL.Clear;
query2.SQL.Add('select * from ration_framer where code='''+temp3+'''');
query2.ExecSQL;
query2.Open;
query2.First;
while not query2.Eof do
begin
temp4:=query2.fieldbyname('material_code').asstring;
if table3.FindKey(['',temp4]) then
begin
if table3.FieldByName('mark').asstring='RG' then
begin
rgf:=rgf+table3.fieldbyname('price1').asfloat*query2.fieldbyname('content').asfloat*query1.fieldbyname('content').asfloat;
end else
if (table3.FieldByName('mark').asstring='CL') or (table3.FieldByName('mark').asstring='CB') then
begin
clf:=clf+table3.fieldbyname('price1').asfloat*query2.fieldbyname('content').asfloat*query1.fieldbyname('content').asfloat;
end else
if table3.FieldByName('mark').asstring='JX' then
begin
jxf:=jxf+table3.fieldbyname('price1').asfloat*query2.fieldbyname('content').asfloat*query1.fieldbyname('content').asfloat;
end;
end;
query2.Next;
end;
query2.Close;
query2.Free;
query1.Next;
end else
begin
temp4:=query1.fieldbyname('material_code').asstring;
if table3.FindKey(['',temp4]) then
begin
if table3.FieldByName('mark').asstring='RG' then
begin
rgf:=rgf+table3.fieldbyname('price1').asfloat*query1.fieldbyname('content').asfloat;
end else
if (table3.FieldByName('mark').asstring='CL') or (table3.FieldByName('mark').asstring='CB') then
begin
clf:=clf+table3.fieldbyname('price1').asfloat*query1.fieldbyname('content').asfloat;
end else
if table3.FieldByName('mark').asstring='JX' then
begin
jxf:=jxf+table3.fieldbyname('price1').asfloat*query1.fieldbyname('content').asfloat;
end;
query1.Next;
end;
end;
end;
query1.Close;
query1.Free;
table1.Edit;
table1.FieldByName('fee').asfloat:=rgf+clf+jxf;
table1.Post;
table1.Next;
table1.Edit;
table1.FieldByName('fee').asfloat:=rgf;
table1.Post;
table1.Next;
table1.Edit;
table1.FieldByName('fee').asfloat:=clf;
table1.Post;
table1.Next;
table1.Edit;
table1.FieldByName('fee').asfloat:=jxf;
table1.Post;
table1.Next;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
table1.Open;
table2.Open;
table3.Open;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
table1.close;
table2.close;
table3.close;
end;
end.