tegryan
Tue Jul 11 15:26:24 CDT 2006
Shoot, one more thing. The file with the function in it is also
another include. In my head this shouldn't matter, but maybe one of
you jeanyuses can help me out here....
The basic structure is this:
main.asp (contains include statements to the other two)
include1.asp (the connection string, set as public)
include2.asp (the function using the connection string that doesn't
work)
Thanks,
Teg Ryan
tegryan@gmail.com wrote:
> yup, works just fine when I put the connection information in the
> function.
>
> Also, I should mention that I'm using Access, not SQL Server. Not sure
> if that matters...
>
> tegr...@gmail.com wrote:
> > Hey Bob, thanks for the quick reply!
> >
> > Firstly, I thought I was using a native OLEDB provider....lol! What am
> > I doing? I haven't created a DSN for that box, and it doesn't look
> > like the DSNless connections I'm used to...
> >
> > Secondly and more importantantly, I forgot to leave out the error
> > message I am getting:
> >
> > Error Type:
> > Microsoft VBScript runtime (0x800A01A8)
> > Object required: 'rs'
> >
> > I am going to double check right now, but I believe that if I copy the
> > connection code into the function in question, it works fine.
> >
> > Thanks!
> >
> > Teg
> >
> > Bob Barrows [MVP] wrote:
> > > tegryan@gmail.com wrote:
> > > > Hey All,
> > > >
> > > > I'm trying to do something that should be very simple, but I think
> > > > I've been up for too many hours or something.
> > > >
> > > > Basically, I have an asp application that uses a database connection,
> > > > and I want to declare (create) that connection in an include and use
> > > > it throughout the application in various functions. I've tried
> > > > making the connection object a public variable, a constant, making
> > > > the functions public, passing the connection object in byRef, byVal,
> > > > etc... I just can't get it to work. Is this not possible in classic
> > > > ASP?
> > > >
> > > > I should also mention that if I take this code out of the function it
> > > > works as expected.
> > > >
> > > > Thanks!
> > > >
> > > > Teg Ryan
> > > >
> > > > Here is a sample of what i'm trying to do:
> > > >
> > > > Include:
> > > >
> > > > <%
> > > >
> > > > public cn
> > > > public rs
> > > > public sql
> > > >
> > > > set cn = Server.CreateObject("ADODB.Connection")
> > > > set rs = Server.CreateObject("ADODB.RecordSet")
> > > > cn.Open "Provider=MSDASQL; Driver={Microsoft Access Driver (*.mdb)};
> > > > DBQ=[[path]];"
> > >
> > > Nothing to do with your problem, but:
> > >
http://www.aspfaq.com/show.asp?id=2126
> > >
> > > >
> > > > %>
> > > >
> > > > Then here's one of the functions in the ASP file that has the include
> > > > at the top:
> > > >
> > > > Function SQLSelect()
> > > >
> > > > sql = "select * from TABLE"
> > > > rs.open sql,cn,3,3
> > > > ... etc
> > > >
> > > > End function
> > >
> > > This should work. What happens when you try it?
> > >
> > > --
> > > Microsoft MVP -- ASP/ASP.NET
> > > Please reply to the newsgroup. The email account listed in my From
> > > header is my spam trap, so I don't check it very often. You will get a
> > > quicker response by posting to the newsgroup.