程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> Access數據庫 >> 關於Access數據庫 >> Access數據庫數據傳遞的實例方法

Access數據庫數據傳遞的實例方法

編輯:關於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

以下為引用的內容:
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
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved