The ado| connection database is added to this module and is invoked anywhere in the program:
Open ADO Database connection: Call Cnndb (MCNN, SCNN, True)
Close ADO Database connection: Call DISCNN (MCNN)
This makes the database connection more convenient to connect and close
'%#******************************************
'%#* form name: MDLDB
'%#* function Description: Call CNNDB (Gcnndb, SCNN, True) after joining this module
'%#* Author: Ning Yanbin
'%#* Date Modified: 2002-12-03
'%#******************************************
'%#*option Explicit
Public Sub cnndb (ByRef mcnn as ADODB. Connection, scnn As String, Optional blnclient as Boolean)
' *purpose:connect Local SQL Server
' *note: Here the data connection
On Error GoTo MYERR
If blnclient = True Then
Mcnn. CursorLocation = adUseClient
Else
Mcnn. CursorLocation = adUseServer
End If
Mcnn. ConnectionString = scnn ' definition of good
Mcnn. Open
Myexit:
Exit Sub
MYERR:
MsgBox "Server not Running" & VbCrLf & Err.Number & vbCrLf & Err.Description, vbcritical, "error"
GoTo Myexit
End Sub
Public Sub discnn (ByRef mcnn as ADODB. Connection)
' *purpose:disconnect Local SQL Server
' *note: Data disconnected here
On Error GoTo MYERR
Mcnn. Close
Set mcnn = Nothing
Myexit:
Exit Sub
MYERR:
GoTo Myexit
End Sub
Function serverdate (ByRef mcnn as ADODB. Connection)
' *purpose: System time taken to the server
' *note: Must be used after the initialization of MCNN
' MsgBox serverdate (MCNN)
On Error GoTo MYERR
Dim rst as New ADODB. Recordset
Set rst = mcnn. Execute ("Select GETDATE ()")
Serverdate = rst (0)
Rst. Close
Set rst = Nothing
Myexit:
Exit Function
MYERR:
GoTo Myexit
End Function
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.