Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with Include File Function

Status
Not open for further replies.

randyripoff

Programmer
Aug 6, 2002
1
US
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 OLEDB:Database 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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top