偶
偶尔幽默
Unregistered / Unconfirmed
GUEST, unregistred user!
数据库是ORACLE,通过D5取得数据集并循环数据集逐条插入TABLE表中,给TABLE表某字段赋值后,发现把原有的尾部空格给去掉了,我想保留空格与原数据集的数据一致,该怎么解决。
部分代码:
tmpTable.Close;
tmpTable.DatabaseName:=tmpdb;
tmpTable.TableName:=Tablename;
tmpTable.TableType:=ttParadox;
tmpTable.FieldDefs.Clear;
For i:=0 to aQuery.FieldDefs.Count-1do
begin
if UpperCase(aQuery.FieldDefs.Name) <> UpperCase('TMP01') then
begin
case aQuery.FieldDefs.DataType of
ftBlob,ftOraBlob:
begin
tmpTable.fielddefs.add(aQuery.FieldDefs.Name,ftBlob,0,aQuery.FieldDefs.Required);
end;
ftDate,ftDateTime,ftTime:
begin
tmpTable.fielddefs.add(aQuery.FieldDefs.Name,ftDateTime,0,aQuery.FieldDefs.Required);
end;
else
begin
tmpTable.fielddefs.add(aQuery.FieldDefs.Name,aQuery.FieldDefs.DataType
,aQuery.FieldDefs.Size,aQuery.FieldDefs.Required);
end;
end;
end;
end;
//for i
tmpTable.IndexDefs.Clear;
Try
TmpTable.CreateTable;
except
Result:=False;
end;
TmpTable.open;
TmpTable.
tcount:=GetRecordCount(aQuery);
f_wait.ProgressBar1.Max:=tcount;
rno:=0;
aQuery.First;
While Not aQuery.Eofdo
begin
f_wait.ProgressBar1.Position:=rno;
Inc(rno);
f_wait.Refresh;
While PeekMessage(msg,0,0,0,PM_REMOVE)do
DispatchMessage(msg);
tmpTable.Append;
For i:=0 to aQuery.FieldDefs.Count-1do
begin
tmpname:=aQuery.FieldDefs.Name;
if UpperCase(tmpname) <> UpperCase('TMP01') then
begin
case aQuery.FieldDefs.DataType of
ftBlob,ftOraBlob:
begin
if Not TBlobField(aQuery.FieldByName(tmpname)).IsNull then
TBlobField(tmpTable.FieldByName(tmpname)).Assign(aQuery.FieldByName(tmpname));
end;
ftDateTime,ftDate,ftTime:
begin
if Not aQuery.FieldByName(tmpname).IsNull then
begin
Try
tmpTable.FieldByName(tmpname).AsdateTime:=aQuery.FieldByName(tmpname).AsDateTime;
Except
end;
end;
end;
else
begin
tmpTable.FieldByName(tmpname).AsString := aQuery.FieldByName(tmpname).AsString;
//这里赋值后,tmptable表中tmpname字段值就去掉了空格
end;
end;
end;
end;
//for i
tmpTable.Post;
部分代码:
tmpTable.Close;
tmpTable.DatabaseName:=tmpdb;
tmpTable.TableName:=Tablename;
tmpTable.TableType:=ttParadox;
tmpTable.FieldDefs.Clear;
For i:=0 to aQuery.FieldDefs.Count-1do
begin
if UpperCase(aQuery.FieldDefs.Name) <> UpperCase('TMP01') then
begin
case aQuery.FieldDefs.DataType of
ftBlob,ftOraBlob:
begin
tmpTable.fielddefs.add(aQuery.FieldDefs.Name,ftBlob,0,aQuery.FieldDefs.Required);
end;
ftDate,ftDateTime,ftTime:
begin
tmpTable.fielddefs.add(aQuery.FieldDefs.Name,ftDateTime,0,aQuery.FieldDefs.Required);
end;
else
begin
tmpTable.fielddefs.add(aQuery.FieldDefs.Name,aQuery.FieldDefs.DataType
,aQuery.FieldDefs.Size,aQuery.FieldDefs.Required);
end;
end;
end;
end;
//for i
tmpTable.IndexDefs.Clear;
Try
TmpTable.CreateTable;
except
Result:=False;
end;
TmpTable.open;
TmpTable.
tcount:=GetRecordCount(aQuery);
f_wait.ProgressBar1.Max:=tcount;
rno:=0;
aQuery.First;
While Not aQuery.Eofdo
begin
f_wait.ProgressBar1.Position:=rno;
Inc(rno);
f_wait.Refresh;
While PeekMessage(msg,0,0,0,PM_REMOVE)do
DispatchMessage(msg);
tmpTable.Append;
For i:=0 to aQuery.FieldDefs.Count-1do
begin
tmpname:=aQuery.FieldDefs.Name;
if UpperCase(tmpname) <> UpperCase('TMP01') then
begin
case aQuery.FieldDefs.DataType of
ftBlob,ftOraBlob:
begin
if Not TBlobField(aQuery.FieldByName(tmpname)).IsNull then
TBlobField(tmpTable.FieldByName(tmpname)).Assign(aQuery.FieldByName(tmpname));
end;
ftDateTime,ftDate,ftTime:
begin
if Not aQuery.FieldByName(tmpname).IsNull then
begin
Try
tmpTable.FieldByName(tmpname).AsdateTime:=aQuery.FieldByName(tmpname).AsDateTime;
Except
end;
end;
end;
else
begin
tmpTable.FieldByName(tmpname).AsString := aQuery.FieldByName(tmpname).AsString;
//这里赋值后,tmptable表中tmpname字段值就去掉了空格
end;
end;
end;
end;
//for i
tmpTable.Post;