时 间:2014-12-05 01:33:40
作 者:摘 要:使用ADO的方式获取Oracle服务器时间
正 文:
Public Function oraTime(Server_name,User_id,Pass_word)
On Error GoTo ErrMsg:
Dim ConnDB As ADODB.Connection
Dim DBRst As ADODB.Recordset
Set ConnDB = New ADODB.Connection
Set DBRst = New ADODB.Recordset
Dim ConnStr As String
Dim SQLRst As String
ConnStr = "Provider = oraOLEDB.Oracle;" & _
"Data Source=" & Server_name & ";" & _
"User ID=" & User_id & ";" & _
"Password=" & Pass_word & ";"
ConnDB.Open ConnStr
SQLRst = "Select sysdate From sys.dual"
DBRst.Open SQLRst, ConnDB, adOpenStatic, adLockBatchOptimistic
oraTime = DBRst.Fields("sysdate")
ConnDB.Close
Set ConnDB = Nothing
Exit Function
ErrMsg:
MsgBox "未能与Oracle数据库建立连接!", vbCritical, "连接失败"
End Function
Access软件网QQ交流群(群号:39785885)
Access源码网店