|
代码如下:运行时现错误:
运行导入数据的时候发生异常:ExcuteSQL:For input string "1986-3-1"类型:Exception
1986-3-1是一个日期型数据,为什么会变成字符串。
Query1.LoadFromFile('E:\测试\zjcs\table_sbjbxx.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 ; |
|