Public conn as New ADODB. Connection
Public rs as New ADODB. Recordset
Public Addflag as Boolean
Public Function OPENCN (ByVal Cip as String) as Boolean
Dim Mag as String
On Error GoTo Strerrmag
Set conn = New ADODB. Connection
Conn. ConnectionTimeout = 25
Conn. Provider = "SQLOLEDB"
Conn. Properties ("Data source"). Value = Name of the CIP server
Conn. Properties ("Initial Catalog"). Value = "Zqoa" ' Library name
' Conn. Properties ("Integrated Security"). Value = "SSPI" ' Landing type
Conn. Properties ("User ID"). Value = "sa"
Conn. Properties ("password"). Value = "sa"
Conn. Open
OPENCN = True
Addflag = True
Exit Function
Strerrmag:
Mag = "Data can ' t connect"
Call MsgBox (Mag, vbOKOnly, "Error:data Connect")
Addflag = False
Exit Function
End Function
Public Sub CLOCN ()
On Error Resume Next
If Conn. State <> adstateclosed Then Conn. Close
Set conn = Nothing
End Sub
Public Function Openrs (ByVal strSQL as String) as Boolean ' connect to a database recordset
Dim Mag as String
Dim Rpy as Boolean
On Error GoTo Strerrmag
Set rs = New ADODB. Recordset
If Addflag = False Then rpy = True
With RS
. ActiveConnection = conn
. CursorLocation = adUseClient
. CursorType = adOpenKeyset
. LockType = adLockOptimistic
. Open strSQL
End With
Addflag = True
Openrs = True
End
' Exit Function
Strerrmag:
MAG = "Data not Connect"
Call MsgBox (Mag, vbOKOnly, "Error:connect")
Openrs = False
End
' Exit Function
End Function
Public Sub clors ()
On Error Resume Next
If Rs. State <> adstateclosed Then Rs. Clone
Set rs = Nothing
End Sub
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.