请教 Adodc访问Access数据库时对象变量或with块变量错误?
用Adodc访问Access数据库定义了一个连接数据库的函数
Public cnn As ADODB.Connection
Public rst As ADODB.Recordset
Public Sub DBConnect()
Dim CONSTER As String
CONSTER = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\luntai\luntai.mdb;Persist Security Info=False "
cnn.ConnectionString = CONSTER
cnn.Open
If cnn.State <> adStateOpen Then
MsgBox "数据库连接失败 ", vbOKOnly + vbCritical, "连接失败 "
End If
End Sub
帮忙看看是代码错误吗
[解决办法]
Public cnn As ADODB.Connection 换成public cnn as new adodb.connetion
Public rst As ADODB.Recordset 换成public rst as new adodb.recordset