Public Eng As RDO.rdoEngine
Public Cng As RDO.rdoConnection
Public Env As RDO.rdoEnvironment
'#############################################################
'连接
'#############################################################
Public Sub DBconnect()
Dim i As Integer
Dim Conn As String
On Error GoTo ERR
Eng = New RDO.rdoEngine
Cng = New RDO.rdoConnection
Env = Eng.rdoCreateEnvironment("MC5", "MC5", "MC5")
Conn = "Uid = MC5; Pwd = MC5; Database = MC5; DSN = MC5 "
Cng = Env.OpenConnection("MC5", RDO.PromptConstants.rdDriverNoPrompt, False, Conn)
Exit Sub
ERR:
For i = 0 To Eng.rdoErrors.Count - 1
errlog = errlog & Now & Eng.rdoErrors.Item(i).Description & vbCrLf
Next
Eng = Nothing
Cng = Nothing
Env = Nothing
End Sub
'#############################################################
'断开
'#############################################################
Public Sub DBdisconnect()
On Error GoTo ERR
Env.Close()
Eng = Nothing
Cng = Nothing
Env = Nothing
Exit Sub
ERR:
Eng = Nothing
Cng = Nothing
Env = Nothing
End Sub