极
极品铁观音
Unregistered / Unconfirmed
GUEST, unregistred user!
这是在网上找到的创建临时表的方法,但编译时在const AFieldDefs:TFieldDefs卡住了不知要如何改才能达到创建临时表的目的: //使用代码创建临时表 // 函数代码如下: function CreateTableInMemory(const AFieldDefs:TFieldDefs):TDataSet; var TempTable:TClientDataSet; begin TempTable:=nil; Result:=nil; if AFieldDefs〈〉nil then begin try TempTable:=TClientDataSet.Create(Application); TempTable.FieldDefs.Assign(AFieldDefs); TempTable.CreateDataSet; Result:=(TempTable as TDataSet); Except if TempTable〈〉nil then TempTable.Free; Result:=nil; raise; end end end; //在程序中按如下方法调用: procedure TForm1.Button1Click(Sender: TObject); var ADataSet:TDataSet; begin ADataSet:=TDataSet.Create(Self); with ADataSet.FieldDefs do begin Add(′Name′,ftString,30,False); Add(′Value′,ftInteger,0,False); end; with DataSource1 do begin DataSet:=CreateTableInMemory(ADataSet.FieldDefs); DataSet.Open; end; ADataSet.Free; end;