|
导出
procedure TYWGNZCT.btExportClick(Sender: TObject);
begin
query1.CommandText:='select * from table_sbjbxx where '
+' GUID=''6FE86CAA67BC4EFBABDB8061ECB22010'' AND SBXZ=''BM1501''';//'select * from table_bmkzb where dwdm=''S11JH001''';
query1.Open;
query1.SaveToFile('E: able_sbjbxx.xml',TDataPacketFormat.dfXML);
query1.Close
end;
导入
procedure TYWGNZCT.btImportClick(Sender: TObject);
var
I,j:Integer;
lValues,lFields,lInsertSQL:string;
lFieldList:TFieldlist;
begin
Query2.LoadFromFile('E: able_sbjbxx.xml');
lFields:='';
lValues:='';
for i:=0 to query2.FieldCount-1 do
begin
if (i<query2.FieldCount-1) then
begin
lFields:=lFields+query2.FieldList.FieldName+',';
lValues:=lValues+':'+query2.FieldList.FieldName+',' ;
end
else begin
lFields:=lFields+query2.FieldList.FieldName ;
lValues:=lValues+':'+query2.FieldList.FieldName;
end
end;
lFields:='('+lFields+')';
lValues:='Values('+lValues+')';
lInsertSQL:='Insert into table_sbjbxx '+lFields+' '+lValues;
QueryInsert.CommandText:=lInsertSQL;
lFieldList:=query2.FieldList;
While not query2.Eof do
begin
for I := 0 to lFieldList.Count - 1 do
begin
QueryInsert.Params.AssignFieldValue(lFieldList[I],lFieldList[I].Value);
end;
QueryInsert.Execute;//运行到该处出错,见图片
query2.Next;
end ;
end;
查其原因,是因为有一个字段JMFDS(number(10)),导出到XML的值
JMFDS=""。上面一段通用导数据表的程序基本不能用,以前发过其它贴,日期型字段空出现问题,blob字段有图片也出现问题。
不知道有什么其它通用方法,导入XML的数据。
|
|