Include file issue

S

Steve Wofford

Why can't I get the following running???

<%
Dim GetODBCdsn
GetODBCdsn = <!--#include virtual="\connections\sqlconnection.txt" -->
Response.Write(GetODBCdsn)
%>

TIA,

Steve
 
S

Steven Burn

Because you are mis-using the #include tag. It's a client-side tag, not a
server side (you also cannot assign it to a var....)

If you want your var to hold the string(s) contained within the file, you
need to first open and read the file, THEN assign the string(s) to your var.

http://aspfaq.com/show.asp?id=2039

--
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!
 
E

Evertjan.

Steven Burn wrote on 27 okt 2005 in
microsoft.public.inetserver.asp.general:
Because you are mis-using the #include tag. It's a client-side tag, not a
server side (you also cannot assign it to a var....)

I strongly disagree, Steven.

<!--#include virtual="\blahDir\blahFile.asp" -->

is serverside

and can [and most often does in my case] contain ASP level code that is
executed inline with other asp code in the master file.

<%
a = 1
%>
<!--#include virtual="\adder.asp" -->
<% 'vbscript
response.write a
' this will write 2 to the rendered html output stream,
' if adder.asp contains <% a = a+1 %>
%>
 
S

Steven Burn

hehe, I know, what I meant was, the #include tag itself is client-side (i.e.
cannot be encased in the <% %> tags), irrespective of what code the included
file does or does not have, it cannot be treat in the same manner.

Hope I'm making sense? (made sense to me whilst I was writing the
reply....lol (I knew what I meant anyway)).

--
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

Evertjan. said:
Steven Burn wrote on 27 okt 2005 in
microsoft.public.inetserver.asp.general:
Because you are mis-using the #include tag. It's a client-side tag, not a
server side (you also cannot assign it to a var....)

I strongly disagree, Steven.

<!--#include virtual="\blahDir\blahFile.asp" -->

is serverside

and can [and most often does in my case] contain ASP level code that is
executed inline with other asp code in the master file.

<%
a = 1
%>
<!--#include virtual="\adder.asp" -->
<% 'vbscript
response.write a
' this will write 2 to the rendered html output stream,
' if adder.asp contains <% a = a+1 %>
%>
 
P

Patrice

#include is not part of VBScript but a server directive. Though you could
try %><!etc..><%, I don't find very clear to include "fragments". I would
rather include a file that contains a whole constant declaration :

<!--#include virtual="/somewhere/settings.inc"-->
<%
Response.Write ConnectionString
'My code
%>

Const ConnectionString="Whatever"
being in the settings.inc file...

Additonaly you'll be able to add other constants to this file if needed...
 

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,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top