Setting up a connection with a function

I am trying to use ASP to create a connection to my database and I have the following connection code:

Set objConn = ConnectDB()
Set objRS   = objConn.Execute(query)

      

I have an include file that I have at the top of my page:

<!--#include FILE=dbcano.inc-->

      

And I am getting this error when I call my page:

Microsoft VBScript Runtime Error "800a01f4" Variable undefined: 'ConnectDB' patti_trinkets.asp, line 9

ConnectDB()

is a function I created that is stored in a file dbcano.inc

.

Any suggestions as to why I am getting this error when calling my page?

My complete code can be found here: http://pastie.org/337183

0


source to share


2 answers


Don't try to try

ConnectDB(objConn) 

      



instead

0


source


Well. It finds the include file because you don't get

"Error active servers" ASP 0126 '

Include file not found. Include File dbcano.inc not found

But your ConnectDB function, which I assume should return a connection object, is not recognized as a function, so it thinks it is an undefined variable.



To find out why we really need to enter the code in the include file as well.

And by the way, be sure to stop your server to serve the content in the .inc -file. Too many times you see sites where the inc file has been moved and some old page is serving the Include file not found. The include file "dbhandler.inc" not found "and you only need to type dbhandler.inc in the browser to get the sql server name / ip, connection string and all that. This is well known but still common, just post error with several more keywords to get a list of available sites.

0


source







All Articles