|
请看一下这段代码,为什么没有保存(写入)数据?
Option Compare Database
Private Sub 命令12_Click()
Dim db As ADODB.Connection, rs As ADODB.Recordset
Set db = New ADODB.Connection
Set rs = New ADODB.Recordset
rs.ActiveConnection = CurrentProject.Connection
rs.Open "商品信息", , adOpenKeyset, adLockPessimistic, adcmtable
If Trim(text1.Value) <> "" Then
rs.AddNew
rs.MoveLast
rs.Fields("名称") = Trim(text1.Value)
rs.Fields("地址") = Trim(text2.Value)
rs.Update
rs.Close
End If
MsgBox "当前总记录数:" & Trim(Str(rs.RecordCount))
End
End Sub
此时记录数仍为0,且打开表后仍无记录。
|
|