?? moddboperate.bas
字號:
Attribute VB_Name = "modDbOperate"
'聲明全局連接
Public CN As ADODB.Connection
'數據庫鏈接打開
Public Sub dbConn()
On Error GoTo dbErr
Dim strConn As String
strConn = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\store.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
'數據庫選擇:ADODB.Recordset
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
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -