ADDNEW方法向ACCESS添加记录的问题
<p>Private Sub UserForm_Initialize()<br/>'创建ADO连接并打开<br/>Set cn = New ADODB.Connection<br/>cn.CursorLocation = adUseClient<br/>cn.Provider = "Microsoft.Jet.oledb.4.0;"<br/>ConStr = "Data Source=C:\Documents and Settings\Administrator\桌面\元数据程序\元数据.mdb;"<br/>cn.Open ConStr</p><p>Set adoRs = New Recordset<br/>adoRs.Open "DLGMetaDataBysheet", cn, adOpenKeyset, adLockBatchOptimistic<br/>If adoRs.RecordCount > 0 Then<br/>adoRs.MoveLast<br/>adoRs.MoveFirst<br/>End If<br/>End Sub</p><p>Private Sub cmdOk_Click()<br/>Dim control As control<br/>On Error GoTo errHandle<br/>With adoRs<br/>.AddNew<br/> .Fields(0) = CInt(txtId.Text)<br/> .Fields(1) = CInt(txtNum.Text)<br/> .Fields(2) = txtName.Text<br/> .Fields(3) = txtHao.Text<br/> .Fields(4) = txtMapName.Text</p><p>.Update<br/> End With</p><p>Exit Sub</p><p>End Sub</p><p>Private Sub UserForm_Terminate()<br/> adoRs.Close<br/> cn.Close<br/>End Sub</p><p>我现在程序运行时可以看到以添加成功,可是为什么数据库里没有记录呢?请高手指教</p> <p>哈哈我已经解决了是我把打开数据表的参数选错了</p>
页:
[1]