C
chhp_tiger
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm1.AdoToDBF(AdoTable: TAdoTable; DbfTable: TTable);
var
i,iSize:integer;
ft:TFieldType;
begin
with ADOTable do
begin
Form1.lbDo.Caption:='正在創建';
Application.ProcessMessages;
if State<>dsInactive then
Close;
Open;
if DbfTable.State<>dsInactive then
DbfTable.fieldDefs.Clear;
for i:=0 to FieldList.Count-1 do
begin
if Fields.DataType=ftWideString then
begin
ft:=ftString;
iSize:=Fields.Size*2;
end
else
begin
ft:=Fields.DataType;
iSize:=Fields.Size;
end;
DbfTable.FieldDefs.Add(Fields.FieldName,ft,iSize,Fields.Required);
end;
DbfTable.CreateTable;
Form1.lbDo.Caption:='正在導出';
Application.ProcessMessages;
DbfTable.Open;
while not eof do
begin
DbfTable.Insert;
for i:=0 to FieldList.Count-1 do
DbfTable.FieldByName(Fields.FieldName).Value:=Fields.Value;
DbfTable.ApplyUpdates;
Application.processMessages;
next;
end;
end;
end;
**********************
調用;
newtable.TableName:='ppp';
AdoToDBF(ADOTable1,newtable);
對DBF我用的是BDE連接.
出現錯誤提示是類型不匹配,請高手指點.
var
i,iSize:integer;
ft:TFieldType;
begin
with ADOTable do
begin
Form1.lbDo.Caption:='正在創建';
Application.ProcessMessages;
if State<>dsInactive then
Close;
Open;
if DbfTable.State<>dsInactive then
DbfTable.fieldDefs.Clear;
for i:=0 to FieldList.Count-1 do
begin
if Fields.DataType=ftWideString then
begin
ft:=ftString;
iSize:=Fields.Size*2;
end
else
begin
ft:=Fields.DataType;
iSize:=Fields.Size;
end;
DbfTable.FieldDefs.Add(Fields.FieldName,ft,iSize,Fields.Required);
end;
DbfTable.CreateTable;
Form1.lbDo.Caption:='正在導出';
Application.ProcessMessages;
DbfTable.Open;
while not eof do
begin
DbfTable.Insert;
for i:=0 to FieldList.Count-1 do
DbfTable.FieldByName(Fields.FieldName).Value:=Fields.Value;
DbfTable.ApplyUpdates;
Application.processMessages;
next;
end;
end;
end;
**********************
調用;
newtable.TableName:='ppp';
AdoToDBF(ADOTable1,newtable);
對DBF我用的是BDE連接.
出現錯誤提示是類型不匹配,請高手指點.