|
发表于 2006-11-30 16:27:42
|
显示全部楼层
procedure TMainForm.BitBtn1Click(Sender: TObject);
var
lFields,lValues,lInsertSQL:String;
i:integer;
lFieldList:TFieldList;
begin
Query1.LoadFromFile('C:\a.xml');
lFields:='';
lValues:='';
for i:=0 to Query1.FieldCount-1 do
begin
if (i<Query1.FieldCount-1) then
begin
lFields:=lFields+Query1.FieldList.FieldName+',';
lValues:=lValues+':'+Query1.FieldList.FieldName+',' ;
end
else begin
lFields:=lFields+Query1.FieldList.FieldName ;
lValues:=lValues+':'+Query1.FieldList.FieldName;
end
end;
lFields:='('+lFields+')';
lValues:='Values('+lValues+')';
lInsertSQL:='Insert into testA '+lFields+' '+lValues;
QueryInsert.CommandText:=lInsertSQL;
lFieldList:=Query1.FieldList;
While not Query1.Eof do
begin
for I := 0 to lFieldList.Count - 1 do
begin
QueryInsert.Params.AssignFieldValue(lFieldList[I],lFieldList[I].Value);
if lFieldList[I].DataType=Business.Data.TFieldType.ftTimeStamp then
QueryInsert.Params[I].DataType := Business.Data.TFieldType.ftDateTime;
end;
QueryInsert.Execute;
Query1.Next;
end ;
end;
procedure TMainForm.BitBtn2Click(Sender: TObject);
begin
if not query1.Active then query1.Open;
query1.SaveToFile('C:\a.xml',business.Data.TDataPacketFormat.dfXML);
end;
以上是我在本地测试的代码,在没有加if lFieldList[I].DataType=Business.Data.TFieldType.ftTimeStamp then
QueryInsert.Params[I].DataType := Business.Data.TFieldType.ftDateTime;
时再高版本下运行就报错。 |
|