nbsp; tDbType(2) = "XLS"
tDbType(3) = "TXT"
tDbType(4) = "FDB"
tDbType(5) = "DDB"
''用户名和密码.
UserPwd(1) = "Uid=" & UserName & ";Pwd=" & PassWord & ";"
UserPwd(2) = "Uid=" & UserName & ";Pwd=" & PassWord & ";"
UserPwd(3) = ""
UserPwd(4) = "Uid=" & UserName & ";Pwd=" & PassWord & ";"
UserPwd(5) = "Uid=" & UserName & ";Pwd=" & PassWord & ";"
On Error Resume Next
If DbConnection.State = adStateOpen And Not IsEmpty(adStateOpen) Then
DbConnection.Close
End If
ConnStr = "Provider=MSDASQL.1;Persist Security Info=False;DRIVER=" & DriveName(DbType) & ";" & UserPwd(DbType) & "DBQ=" & FilePath
DbConnection.ConnectionString = ConnStr
DbConnection.Open
DoEvents
If Err.Number = 0 Then
DbStyle = tDbType(DbType)
CreateOtherConn = True
Else
Err.Clear
DbStyle = ""
CreateOtherConn = False
End If
End Function
上面的只是常见的数据库类型。当然,只要你愿意,你可以在ODBC 或
注册表里将 驱动程序 继续添加上去。例如我的电脑上有的驱动
程序如下:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers]
"SQL Server"="Installed"
"Microsoft Access Driver (*.mdb)"="Installed"
"Microsoft Text Driver (*.txt; *.csv)"="Installed"
"Microsoft Excel Driver (*.xls)"="Installed"
"Microsoft dBase Driver (*.dbf)"="Installed"
"Microsoft Paradox Driver (*.db )"="Installed"
"Microsoft Visual FoxPro Driver"="Installed"
"Microsoft FoxPro VFP Driver (*.dbf)"="Installed"
"Microsoft dBase VFP Driver (*.dbf)"="Installed"
"Microsoft