randyripoff
Programmer
Okay, this is stupid.
I have a simple script to connect to an Access database and write out the records available. Since I am using the same db on several different pages, I want to use a function in an include file to define the connection string.
When I attempt to run the ASP page, I get the following error:
Microsoft VBScript runtime (0x800A000D)
Type mismatch: 'connecttoRJ'
Here's the lines of code causing the problem:
set db=Server.CreateObject("ADODB.Connection"
cn=connecttoRJ()
db.open(cn)
Here's the function I created.
function ConnecttoRJ()
'this creates the connection string for use within this application
ConnecttoRJ="Provider=Microsoft.Jet.OLEDB.4.0;"
ConnecttoRJ=ConnecttoRJ & "Data Source=pathtodb/dbname;"
ConnecttoRJ=ConnecttoRJ & "Jet OLEDBatabase Password=password"
end function
If I copy and paste the function directly into the page, it works okay, although for some reason it prints the function at the top of the page.
This doesn't make any sense to me. All I'm trying to do is create a string for use within the application. I could just put the connection string information on every page, but I'd like to keep my code as clean as possible, and putting a few common functions into an include file should work, right?
I'm using Windows 2000 and IIS 5.0. If anyone can spot the stupid thing I'm doing and let me know, I'd be very appreciative.
I have a simple script to connect to an Access database and write out the records available. Since I am using the same db on several different pages, I want to use a function in an include file to define the connection string.
When I attempt to run the ASP page, I get the following error:
Microsoft VBScript runtime (0x800A000D)
Type mismatch: 'connecttoRJ'
Here's the lines of code causing the problem:
set db=Server.CreateObject("ADODB.Connection"
cn=connecttoRJ()
db.open(cn)
Here's the function I created.
function ConnecttoRJ()
'this creates the connection string for use within this application
ConnecttoRJ="Provider=Microsoft.Jet.OLEDB.4.0;"
ConnecttoRJ=ConnecttoRJ & "Data Source=pathtodb/dbname;"
ConnecttoRJ=ConnecttoRJ & "Jet OLEDBatabase Password=password"
end function
If I copy and paste the function directly into the page, it works okay, although for some reason it prints the function at the top of the page.
This doesn't make any sense to me. All I'm trying to do is create a string for use within the application. I could just put the connection string information on every page, but I'd like to keep my code as clean as possible, and putting a few common functions into an include file should work, right?
I'm using Windows 2000 and IIS 5.0. If anyone can spot the stupid thing I'm doing and let me know, I'd be very appreciative.