include file levels??

R

rich

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

default.asp:
<%@ Language=VBScript %>
<!--#include file="ExecuteSQL.asp"-->
<html>
....
<tr><td><!--#include File="login.asp"--></td></tr>
....
</html>

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?
 
R

rich

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top