首页 > 开发 > 综合 > 正文

一个ACCESS数据库数据传递的方法

2024-07-21 02:12:25
字体:
来源:转载
供稿:网友
一直以来,access数据库中的申报数据在分公司与总公司之间传递,用excel或dbase、txt甚至access等格式,我总觉得不太理想。最近看了一本书,不经意间发现了一个方法,使用access数据库生成申报数据与读入数据似乎简单了不少,特拿出来与大家分享。同时,也希望能得到更多的指点。

附上示例:

sub mwrite()
on error goto thiserr
dim rs as new adodb.recordset
rs.open "dlmd", currentproject.connection, adopendynamic, adlockoptimistic, actable
rs.save "a:/dlmd.adtg", adpersistadtg
rs.close
set rs = nothing
thisexit:
exit sub
thiserr:
msgbox err.description
resume thisexit
end sub
sub mread()
on error goto merr
dim i as integer
dim rsde as new adodb.recordset
dim rsso as new adodb.recordset
rsso.open "a:/dlmd.adtg", "provider=mspersist"
rsde.open "dlmd", currentproject.connection, adopenkeyset, adlockoptimistic, actable
do until rsso.eof
rsde.addnew
for i = 0 to rsso.fields.count - 1
rsde.fields(i) = rsso.fields(rsde.fields(i).name)
next i
rsde.update
rsso.movenext
loop
rsso.close
rsde.close
set rsso = nothing
set rsde = nothing
mexit:
exit sub
merr:
msgbox err.description
resume mexit
end sub


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表