excel首行空不能导入access_excel中的空字符导入到access中,数值字段却变为0,不为空 ( 积分: 200 )...

转换的源码

procedure TfrmConvertDB.btnOKClick

(Sender:TObject);

variField:integer;

begin

if ((edTotbl.text<>'') and (edFromtbl.text<>'')) then

begin

tblSource.TableName:=edFromtbl.text; {指定TableName}

tblDest.TableName:=edTotbl.text;

with tblSource do

begin

Open;{打开老系统的表}

While EOF=FALSE do

begin{逐条记录处理}

qryInsert.SQL.Clear;

qryInsert.sql.Add('Insert into'+edTotbl.text+' ( ' );

for iField:=0 to dbg.FieldCount-1 do

begin

qryInsert.sql.add(dbg.Fields[iField].DisplayLabel);

if iField<>dbg.FieldCount-1then

qryInsert.sql.add('');

end;

qryInsert.sql.add(' )values(' );

for iField:=0 to dbg.FieldCount-1 do

begin

{进行数据类型转换}

if dbg.fields[iField].DataType=ftInteger then

qryInsert.sql.add(inttostr(dbg.fields[iField].asInteger));

if dbg.fields[iField].DataType=ftFloat then

qryInsert.sql.add(floattostr(dbg.fields[iField].asFloat));

if dbg.fields[iField].DataType=ftDate then

qryInsert.sql.add(''''+datetostr(dbg.fields[iField].asDateTime)+'''');

if dbg.fields[iField].DataType=ftString then

begin

if dbg.fields[iField].asString<>'' then

qryInsert.sql.add(''''+dbg.fields[iField].asString+'''')

else

qryInsert.sql.add('NULL');

end;

if iField<>dbg.FieldCount-1 then qryInsert.sql.add(' ');

end;

qryInsert.sql.add(')');

qryInsert.ExecSQL; {把数据插入到新系统的表中}

next;

end;

end;

tblDest.Close;

tblDest.Open;;

ShowMessage('转换完毕!');

end

else

ShowMessage('请输入要插入数据的表的名称');

end;

end.

建立的access数据库的数值字段可以为空,没有强制非空

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值