Syntax Error on 'Sub mysub()' Include File

S

Susan Cranford

I know this is simple but I'm new with it and can't see it. I am
calling this sub from an ASP page right after the
<html> tag as:
<!-- #include file="genproc.inc"-->

Then I call the sub below in the asp in the validate routine to 'Call
ConnectDB'

The connection itself is okay.

But, the page will not even display, I get a syntax error on the 'Sub
Connect()' line of this file (include file) :
------------------------
<html>
<head>
</head>
<body>
<%
Sub ConnectDB()
' Database Connection
Dim sConn, dcn
sConn = "Provider=SQLOLEDB; " & _
"Data Source=nnn.nnn.nnn.nnn\ServerName; " & _
"Database=theDB; " & _
"User ID=aUser; " & _
"Password=aUserPW;"
Set dcn = Server.CreateObject("ADODB.Connection")
dcn.ConnectionString = sConn
dcn.Open
End Sub
%>
</body>
</html>
 
B

Bob Barrows

Susan said:
I know this is simple but I'm new with it and can't see it. I am
calling this sub from an ASP page right after the
<html> tag as:
<!-- #include file="genproc.inc"-->

Then I call the sub below in the asp in the validate routine to 'Call
ConnectDB'

The connection itself is okay.

But, the page will not even display, I get a syntax error on the 'Sub
Connect()' line of this file (include file) :
------------------------
<html>
<head>
</head>
<body>
<%
Sub ConnectDB()
' Database Connection
Dim sConn, dcn
sConn = "Provider=SQLOLEDB; " & _
"Data Source=nnn.nnn.nnn.nnn\ServerName; " & _
"Database=theDB; " & _
"User ID=aUser; " & _
"Password=aUserPW;"
Set dcn = Server.CreateObject("ADODB.Connection")
dcn.ConnectionString = sConn
dcn.Open
End Sub
%>
</body>
</html>
Get rid of the html tags in this page. Only include the server-side script
block.

Bob Barrows
 

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

Forum statistics

Threads
474,146
Messages
2,570,832
Members
47,374
Latest member
anuragag27

Latest Threads

Top