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