连接到经典ASP中的数据库

时间:2018-07-02 17:25:19

标签: vba asp-classic

我有其他人编写的旧代码,最近在服务器升级期间损坏了。

我已经创建了32位DSN连接和64位DSN连接。

下面是32位的错误。

Microsoft OLE DB Provider for ODBC Drivers error '80004005'

[Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application

/path/to/connection/file.asp, line 12 

出现上述错误的代码是:

<%
dim Conn
Dim powerConn
dim connstr
Dim pconnstr
connstr = Application("databaseA")
pconnstr = Application("databaseB")
Sub openConnection()
    Set Conn = Server.CreateObject("ADODB.Connection")
    Conn.ConnectionTimeout = 600
    Conn.CommandTimeout = 600
    Conn.Open connstr // Error occurs here
    Set pConn = Server.CreateObject("ADODB.Connection")
    pConn.Open pconnstr
End Su

Sub closeConnection()
    Conn.close
    set Conn = Nothing
    pConn.Close
    set pConn = Nothing
End Sub
%>

然后我尝试了64位连接并收到此错误:

Microsoft OLE DB Provider for ODBC Drivers error '80004005'

[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

/path/to/connection/file.asp, line 12 

出现上述错误的代码是:

<%
dim Conn
Dim powerConn
dim connstr
Dim pconnstr
connstr = Application("databaseA_64bit")
pconnstr = Application("databaseB_64bit")
Sub openConnection()
    Set Conn = Server.CreateObject("ADODB.Connection")
    Conn.ConnectionTimeout = 600
    Conn.CommandTimeout = 600
    Conn.Open connstr // Error occurs here
    Set pConn = Server.CreateObject("ADODB.Connection")
    pConn.Open pconnstr
End Su

Sub closeConnection()
    Conn.close
    set Conn = Nothing
    pConn.Close
    set pConn = Nothing
End Sub
%>

我需要帮助解决此问题,以便所有评论都感激不尽。

1 个答案:

答案 0 :(得分:1)

通常在global.asa中为经典ASP应用程序分配应用程序变量。由于您的连接字符串似乎是从Application("databaseA_64bit")分配的,因此您应该去那里查找连接字符串。

DSN配置最常见的是“控制面板”>“管理工具”>“数据源”>“用户/本地/系统DSN”。