日期:2014-05-16  浏览次数:20449 次

关于asp+access 一个网站多个数据库连接文件问题

解决办法:

????? 利用FSO.FileExists组件判断

?

????? Dim DbPath:DbPath="dbPath/Dnname.mdb"

????? Set Fso=Server.CreateObject("Scripting.FileSystemObject")

?

????? If Fso.FileExists(Serer.mappath(DbPath)) then

??????????? DbPath="dbPath/Dnname.mdb"

????? elseIf Fso.FileExists(Serer.mappath("../"&DbPath)) then?

??????????? DbPath="../dbPath/Dnname.mdb"

????? elseIf Fso.FileExists(Serer.mappath("../../"&DbPath)) then?

??????????? DbPath="../../dbPath/Dnname.mdb"

?????? end If

?

?????? Set Conn=Server.CerateObject("Adodb.Connection")

??????

?????? Dim ConnStr

?????? ConnStr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.mappath(DbPath)

?????? Conn.Open ConnStr