代码讲解?
Public CN As ADODB.ConnectionPublic Sub dbConn()
On Error GoTo dbErr
Dim strConn As String
strConn = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\data\shop.mdb"
Set CN = New ADODB.Connection
CN.Open strConn
Exit Sub
dbErr:
MsgBox Err.Description, , "商店销售系统"
End Sub
Public Sub dbClose()
On Error GoTo dbErr
CN.Close
Set CN = Nothing
Exit Sub
dbErr:
MsgBox Err.Description, , "商店销售系统"
End Sub
Public Sub dbOperate(strSql As String)
On Error GoTo dbErr
dbConn
CN.Execute strSql
dbClose
MsgBox "操作成功!", , "提示"
Exit Sub
dbErr:
MsgBox Err.Description, , "商店销售系统"
End Sub
Public Sub dbOperateW(strSql As String)
On Error GoTo dbErr
dbConn
CN.Execute strSql
dbClose
Exit Sub
dbErr:
MsgBox Err.Description, , "商店销售系统"
End Sub
Public Function dbSelect(strSql As String) As ADODB.Recordset
Dim RS As New ADODB.Recordset
On Error GoTo dbErr
dbConn
Set RS = CN.Execute(strSql)
Set dbSelect = RS
Exit Function
dbErr:
MsgBox Err.Description, , "商店销售系统"
End Function
有没有高手详细讲解一下段代码?呵呵,谢谢了。我是vb的初学者,做课设下代码。看不懂。