是啊,
前面几人都已经说了, 用TDataProvider绑定即可
在delphi5开发人员批南中有:
function GetData( ADataSet:TDataSet):OleVariant;
begin
with TDataSetProvider.Create(nil)do
begin
DataSet := ADataSet;
Result := Data;
end;
end;
调用:
ClientDataSet1.Data := GetData(AdoDataSet1)
即可,
还有我以前写过直接将数据集转换:
function RcdsetToData(const ARcdSet: _RecordSet): OleVariant;
var
ads: TAdoDataSet;
cds: TClientDataSet;
FCount: Integer;
I: Integer;
begin
{ A Ado Dataset's(TAdoDataSet,TAdoTable,TAdoQuery) RecordSet
Trans to A ClientDataSet's RecordSet}
ads := TAdoDataSet.Create(Nil);
cds := TClientDataSet.Create(Nil);
try
ads.Recordset := ARcdSet;
FCount := ads.FieldCount;
for i:=0 to FCount-1do
begin
with cds.FieldDefs.AddFieldDefdo
begin
Name := ads.Fields.FieldName;
DataType := ads.Fields.DataType;
Size := ads.Fields.Size;
end;
end;
cds.CreateDataSet;
ads.First;
While not ads.Eofdo
begin
cds.Append;
for I:=0 to FCount-1do
cds.Fields.Value := ads.Fields.Value;
cds.Post;
ads.Next;
end;
Result:= cds.Data;
finally
ads.Free;
cds.Free;
end;
end;
调用时只要: ClientDataset1.Data :=RcdsetToData(AdoDataSet1.RecordSet)即可,
当然, 也可用AdoQuery等等