?? dblink.bas
字號:
Attribute VB_Name = "DBLink"
Option Explicit
Public con As ADODB.Connection
Public com As ADODB.Command
Public rs As ADODB.Recordset
Public strSysUser As String '當前系統用戶,登錄以后存儲
Public objDBOpt As New clsDbOpt '系統通用的連接對象,在登錄頁面加載的時候創建
Public Const strConnStr = "provider=sqloledb;server=211.68.42.140;uid=sa;pwd=admin;database=CMS"
Public sqlstr As String
Public Sub Connect(ByVal mode As String)
Set con = New ADODB.Connection
Set rs = New ADODB.Recordset
Set com = New ADODB.Command
con.ConnectionString = strConnStr
'con.ConnectionString = "provider=sqloledb;server=211.68.42.143;uid=sa;pwd=wpd;database=CCMS"
'con.ConnectionString = "provider=MSDASQL;driver=SQLServer;server=211.68.42.143;database=CCMS;uid=sa;pwd=wpd"
'con.ConnectionString = "provider=MSDASQL;server=211.68.42.143;database=CCMS;uid=sa;pwd=wpd"
con.CursorLocation = adUseClient
con.ConnectionTimeout = 40
con.Open
If mode = "r" Or mode = "R" Then
rs.cursorType = adOpenDynamic
ElseIf mode = "w" Or mode = "W" Then
rs.lockType = adLockOptimistic
rs.cursorType = adOpenKeyset
Else
MsgBox "表的讀寫模式錯誤,參數應該為r 或 R和w 或 W"
Disconnect
Exit Sub
End If
rs.CursorLocation = adUseClient
rs.ActiveConnection = con
com.ActiveConnection = con
End Sub
Public Sub Disconnect()
If con.State = 1 Then
con.Close
Set rs = Nothing
Set com = Nothing
Set con = Nothing
Else
MsgBox "與數據庫的連接尚未斷開,程序將自動關閉!"
End
End If
End Sub
Sub main()
'Dim n As newequipment
'Set n = New newequipment
'n.name = "計算機"
'n.value = 4568
'n.buytime = Date
'n.ccount = 34
'n.storeid = "a"
'n.Insert
'Dim s As store
'Set s = New store
's.storeid = "a"
's.Insert
'frmconfig.Show
'frmRepair.Show
'frmUseless.Show
'frmEquipment.Show
'frmNewequipment.Show
'frmCroom.Show
'frmStore.Show
'frmRoom.Show
frmMain.Show
'Dim s As store
'Set s = New store
's.storeid = "1倉庫"
's.operator = "汪品端"
's.address = "3公寓內"
'MsgBox s.storeid & s.operator & s.address
's.Insert
'Set s = Nothing
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -