www.pudn.com > vb625557712344.rar > DbFunc.bas, change:2004-05-05,size:1397b
Attribute VB_Name = "DbFunc"
Private IsConnect As Boolean
Private Connect_Num As Integer
Private cnn As ADODB.Connection
Private rs As ADODB.Recordset
Private Sub Connect()
If IsConnect = True Then
Exit Sub
End If
Set cnn = New ADODB.Connection
cnn.ConnectionString = Conn
cnn.Open
If cnn.State <> adStateOpen Then
MsgBox "Êý¾Ý¿âÁ¬½Óʧ°Ü"
End
End If
IsConnect = True
End Sub
Private Sub Disconnect()
Dim Rc As Long
If IsConnect = False Then
Exit Sub
End If
cnn.Close
Set cnn = Nothing
IsConnect = False
End Sub
Public Sub DB_Connect()
Connect_Num = Connect_Num + 1
Connect
End Sub
Public Sub DB_Disconnect()
If Connect_Num >= CONNECT_LOOP_MAX Then
Connect_Num = 0
Disconnect
End If
End Sub
Public Sub DBapi_Disconnect()
Connect_Num = 0
Disconnect
End Sub
Public Sub SQLExt(ByVal TmpSQLstmt As String)
Dim cmd As New ADODB.Command
DB_Connect
Set cmd.ActiveConnection = cnn
cmd.CommandText = TmpSQLstmt
cmd.Execute
Set cmd = Nothing
DB_Disconnect
End Sub
Public Function QueryExt(ByVal TmpSQLstmt As String) As ADODB.Recordset
Dim rst As New ADODB.Recordset
DB_Connect
Set rst.ActiveConnection = cnn
rst.CursorType = adOpenDynamic
rst.LockType = adLockOptimistic
rst.Open TmpSQLstmt
Set QueryExt = rst
End Function