H
hj6
Unregistered / Unconfirmed
GUEST, unregistred user!
请问大家以下这个自定义函数有什么错误的地方,请指点:
function CopyFromTQueryToTTable(Query: TQuery;
var Table: TTable;
var BMove: TBatchMove): Boolean;
var
i: Integer;
begin
Result := False;
try
with Table do begin
Close;
FieldDefs.clear;
for i := 0 to Query.FieldDefs.Count-1 do
FieldDefs.Add(Query.FieldDefs.Items.Name,
Query.FieldDefs.Items.DataType,
Query.FieldDefs.Items.Size,
Query.FieldDefs.Items.Required);
IndexDefs.Clear;
end;
Table.CreateTable;
except
MessageDlg( 'An error has ocurred while creating the tmp table ' + #13 +
'Check that all the fields of the original table are compatible
with that of destination.' , mtError,[mbCancel], 0 );
Exit;
end;
with Table2 do begin
Close;
DataBaseName := Directory1.Directory;
TableName := 'Tmp.dbf';
TableType := ttdefault;
end;
{# Execute the query copy}
with BMove do begin
Source := Query;
Destination := Table;
Mode := batAppend;
Execute;
end;
Table.Close;
Result := True;
end;
在public去定义的CopyFromTQueryToTTable函数。我用Delphi4+win95。我觉得从字面看
没有什么问题,但是一运行就提示说这个函数和前面定义的类型不同,请大家帮忙。谢谢!
function CopyFromTQueryToTTable(Query: TQuery;
var Table: TTable;
var BMove: TBatchMove): Boolean;
var
i: Integer;
begin
Result := False;
try
with Table do begin
Close;
FieldDefs.clear;
for i := 0 to Query.FieldDefs.Count-1 do
FieldDefs.Add(Query.FieldDefs.Items.Name,
Query.FieldDefs.Items.DataType,
Query.FieldDefs.Items.Size,
Query.FieldDefs.Items.Required);
IndexDefs.Clear;
end;
Table.CreateTable;
except
MessageDlg( 'An error has ocurred while creating the tmp table ' + #13 +
'Check that all the fields of the original table are compatible
with that of destination.' , mtError,[mbCancel], 0 );
Exit;
end;
with Table2 do begin
Close;
DataBaseName := Directory1.Directory;
TableName := 'Tmp.dbf';
TableType := ttdefault;
end;
{# Execute the query copy}
with BMove do begin
Source := Query;
Destination := Table;
Mode := batAppend;
Execute;
end;
Table.Close;
Result := True;
end;
在public去定义的CopyFromTQueryToTTable函数。我用Delphi4+win95。我觉得从字面看
没有什么问题,但是一运行就提示说这个函数和前面定义的类型不同,请大家帮忙。谢谢!