cdub
cdub

Reputation: 25711

Connecting to a database in classic asp

I have old code written by someone else that recently broke during a server upgrade.

I have created a 32-bit DSN connections and a 64 bit DSN connections.

The error for the 32 bit is below.

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 

The code with the above error is:

<%
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
%>

I then tried the 64 bit connections and got this error:

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 

The code with the above error is:

<%
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
%>

I need help fixing this so any comments are greatly appreciated.

Upvotes: 0

Views: 697

Answers (1)

mjw
mjw

Reputation: 1206

Application variables are typically assigned in the global.asa for classic ASP applications. Since your connection string appears to be assigned from Application("databaseA_64bit") you should take a look there to find your connection string.

The DSN configurations are most commonly in Control Panel > Admin Tools > Data Sources > User/Local/System DSN.

Upvotes: 1

Related Questions