一个ACCESS数据库数据传递的方法
时间:2007-12-23 来源:不详 作者:迈克DB
一直以来,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
内容来自dedecms
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
上一篇:在Delphi中的Access技巧集 下一篇:access中数据表的自动重新联接
文章评论
共有位Admini5网友发表了评论 查看完整内容