include file levels??

include file levels??

am 06.09.2007 20:27:51 von Rich

I have 3 asp pages that look sort of like this:

default.asp:
<%@ Language=VBScript %>


....

....


login.asp:
<%
dim SQL, rs
SQL = "select * from [user] where..."
rs = GetData(SQL) 'this function is in ExecuteSQL.asp
....
%>
....

ExecuteSQL.asp:
<%
Public Function GetData(SQL)
set objRec = server.CreateObject("adodb.recordset")
objRec.Open SQL,objCon
End Function
%>

The problem is that if I include "ExecuteSQL.asp" directly into the
Login.asp page that invokes the function it works fine. When I move
the include ExecuteSQL.asp to the parent file - Default.asp - it
returns a type mismatch (which I have deduced really means it doesn't
know what the heck GetData is).

I can move the include statement into Login.asp, but I have more
includes of other ASP files in default.asp and it won't let me include
ExecuteSQL.asp in each of them.

Is there an easy way around this?

Re: include file levels??

am 06.09.2007 21:00:31 von Rich

On Sep 6, 2:27 pm, rich wrote:

crud! I understand what's going on now that I better understand 2
things:
1) the includes go first - period. so all code is brought together
before any interpretation of the ASP code
2) the code is processed server-side and does not exist once it is
rendered as HTML to the client

So, my problem (when the include ExecuteSQL.asp was in the Default.asp
page) was that when I tried to logon using login.asp, it submitted
only the login.asp page which no longer had access to the functions in
ExecuteSQL.asp which was included only upon loading Default.asp. The
submit did not reload Default.asp, this no GetData function.

If I put the include ExecuteSQL.asp in the Login.asp file it worked
there, but once logged in that page was gone never to return and thus
my other ASP pages would never have access to functions in a file
included in login.asp

DUH! Hopefully, someone can learn from my mistake.