|

楼主 |
发表于 2007-1-23 15:22:55
|
显示全部楼层
对不起,因为忙于其它工作,所以没有时间跟贴
导出代码
procedure TMainForm.btExportClick(Sender: TObject);
begin
Query1.CommandText:='select * from table_SBJBXX where SSDW like ''S11JH0340030%''';
Query1.open;
Query1.SaveToFile('E:\SBJBXX_2617.XML',TDatapacketFormat.dfXML) ;
end;
导入代码
procedure TMainForm.btImportClick(Sender: TObject);
var
I:Integer;
lFields,lValues,lInsertSQL:string;
lFieldList: TFieldList;
begin
Query1.LoadFromFile('E:\SBJBXX_2617.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 table_SBJBXX '+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);
end;
QueryInsert.Execute;//运行该语句时出错
Query1.Next;
end ;
end;
仍然出现1楼的错误,因为图片字段插入了jpg文件 |
|