ADO连接Oracle/Access示例及记录集处理源码
复制内容到剪贴板程序代码
Option Explicit
Public Enum RSMethod
VIEW_RECORD [color=#0000ff]= 0
EDIT_RECORD = 1
EXEC_SQL = 2
NEW_RECORD = 3
End Enum
Function dbConnection(strDatabaseType As String, strDBService As String, Optional strUserID As String, Optional strPassword As String) As ADODB.Connection
Dim objDB As New ADODB.Connection
Dim strConnectionString As String
If strDatabaseType ="ORACLE" Then
'定义 orACLE 数据库连接字符串
strConnectionString ="Driver={Microsoft ODBC Driver For oracle};ConnectString="& strDBService &";UID="& strUserID &
";PWD="& strPassword &";"
ElseIf strDatabaseType ="MSACCESS" Then
'定义 Microsoft Access 数据库连接字符串
strConnectionString ="DBQ="& strDBService
strConnectionString ="DRIVER={Microsoft Access Driver (*.mdb)}; "& strConnectionString
End If
With objDB
.Mode = adModeReadWrite ' 连接模式 ???
.ConnectionTimeout = 10 '超时