|
Public Sub AddNewRecord()
Dim rs As New ADODB.Recordset
rs.Open "Contacts", CurrentProject.Connection, , adLockOptimistic
With rs
.AddNew
![fieldsArray] = "55"
![valuesArray] = "66"
.Update
End With
rs.Update
rs.Close
Set rs = Nothing
End Sub
新增、修改以及堆栈记录 access ado
新增:
Public Sub AddNewRecord(aa As String, bb As String)
Dim rs As New ADODB.Recordset
rs.Open "Contacts", CurrentProject.Connection, , adLockOptimistic
With rs
.AddNew
![fieldsArray] = aa & bb
![valuesArray] = Date
.Update
End With
rs.Update
rs.Close
Set rs = Nothing
End Sub
Public Sub hello()
'Call AddNewRecord("hello", "朝鲜")
Call ModifyRecord("lol", " 旭")
End Sub
修改:
Public Sub ModifyRecord(cc As String, dd As String)
Dim rs As New ADODB.Recordset
rs.Open "select * from Contacts where ID = 45", CurrentProject.Connection, , adLockOptimistic
rs![fieldsArray] = cc
rs![valuesArray] = cc & dd
rs.Update
rs.Close
Set rs = Nothing
End Sub
堆栈:
Public Sub roll()
Dim rs As New ADODB.Recordset
Dim aa As String
aa = "哈哈哈"
rs.Open "select * from Contacts ", CurrentProject.Connection, , adLockOptimistic
While rs.EOF = False
aa = aa & rs!fieldsArray
rs.MoveNext
Wend
MsgBox (aa)
rs.Close
Set rs = Nothing
End Sub |
|