Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Option Explicit 1

Status
Not open for further replies.

PhatH

IS-IT--Management
Mar 30, 2004
88
US
Good afternoon,

I start over again learning ASP the right way.

While adding
<%@ Language=VBScript %>
<% Option Explicit %>

I got an ERROR:
Active Server Pages, ASP 0140 (0x80004005)
The @ command must be the first command within the Active Server Page.
/includes/htmltop.asp, line 1

I look around in my book but found no definition about such ERROR.
 
I believe the quotes must be around VBScript
<%@ Language="VBScript" %>

Although this line is not needed if you are writing in pure VBScript as the language for ASP's. VBScript is the default language so it is literally just information to me at that point.



___________________________________________________________________

The answer to your ??'s may be closer then you think. faq333-3811
Join the Northern Illinois/Southern Wisconsin members in Forum1064
 
Thank you onpnt,

How about this ERROR:

Microsoft VBScript compilation (0x800A0411)
Name redefined
/includes/subnav/printers_subnav.asp, line 2, column 4

I'm keep getting ERRORs since I start adding Option Explicit :)
 
is this the very first lines in the page? It must be or it will cause all kinds of funny errors. Even empty lines will cause problems.


Thanks for the star!

___________________________________________________________________

The answer to your ??'s may be closer then you think. faq333-3811
Join the Northern Illinois/Southern Wisconsin members in Forum1064
 
:) You're right, this is a very funny error.

That ERROR points right at this part:

<%
Dim ManuSQL
Dim rs
ManuSQL = "SELECT * FROM tblManufacturers"
Set rs = objConn.Execute(ManuSQL)

Dim ProdTypeSQL, rs2
ProdTypeSQL = "SELECT * FROM tblProductType"
Set rs2 = objConn.Execute(ProdTypeSQL)

Dim sql1, rs1
sql1 = "SELECT DISTINCT ProdTypeID FROM tblProducts WHERE ManuID = '" & request.querystring("ManuID") & "'"
Set rs1 = objConn.Execute(sql1)

Dim sql2, rs4
sql2 = "SELECT * FROM tblManufacturers WHERE ManuID IN (SELECT DISTINCT ManuID FROM tblProducts WHERE ProdTypeID like '%" & request.querystring("ProdTypeID") & "%')"
Set rs4 = objConn.Execute(sql2)
%>

No matter where I move the first line: DIM ManuSQL, the error will follow that line accordingly.
 
You know what,

The ERROR doesn't point to that specific DIM MenuSQL,
instead, it just point to the very first line of the code.
 
What is the first line of code in the page?

If it is not the Option Explicit then it needs to be

___________________________________________________________________

The answer to your ??'s may be closer then you think. faq333-3811
Join the Northern Illinois/Southern Wisconsin members in Forum1064
 
This page is a include file that was added to my another page. The main is already contain the Option Explicit.

However, I did add the Option Explicit to the top of the page and got another ERROR:

Error Type:
Microsoft VBScript compilation (0x800A0400)
Expected statement
/includes/subnav/printers_subnav.asp, line 1

:) It seems that today is my ERRORs day or something.
 
[lol] @ day of errors

The option explicit is just showing you errors that may have not been caught before. It was good advice from Tarwn and on your part by adding it.

Can you post the line of code and any relavent code that applies to it. also when you get errors post the line it is pointing to. helps a bit in trouble shooting the problem :)

___________________________________________________________________

The answer to your ??'s may be closer then you think. faq333-3811
Join the Northern Illinois/Southern Wisconsin members in Forum1064
 
This is a portion of the whole page where the ERROR pointing to:

<%
Dim rs
Dim MSQL1

MSQL1 = "SELECT * FROM tblManufacturers"
Set rs = objConn.Execute(MSQL1)

Dim ProdTypeSQL, rs2
ProdTypeSQL = "SELECT * FROM tblProductType"
Set rs2 = objConn.Execute(ProdTypeSQL)

Dim sql1, rs1
sql1 = "SELECT DISTINCT ProdTypeID FROM tblProducts WHERE ManuID = '" & request.querystring("ManuID") & "'"
Set rs1 = objConn.Execute(sql1)

Dim sql2, rs4
sql2 = "SELECT * FROM tblManufacturers WHERE ManuID IN (SELECT DISTINCT ManuID FROM tblProducts WHERE ProdTypeID like '%" & request.querystring("ProdTypeID") & "%')"
Set rs4 = objConn.Execute(sql2)
%>
<table width=197 bgcolor="#dbdbdb" border=0 cellpadding="5" cellspacing=0
style="border: 1px solid #021FFC; border-left-width:0px; border-top-width:0px">
<tr>
<td valign="top" align="left">
<span class="normaltxt">

The ERROR:
Microsoft VBScript compilation (0x800A0411)
Name redefined
/includes/subnav/printers_subnav.asp, line 2, column 4

points to Dim rs.

When I deleted Dim rs, Dim MSQL1, the ERROR moves to line 7 where the very next Dim is located.
 
take a look here

make sure the complete script (includes and all) are formatted this way.



___________________________________________________________________

The answer to your ??'s may be closer then you think. faq333-3811
Join the Northern Illinois/Southern Wisconsin members in Forum1064
 
the error you are getting is showing that the variables are already declared, either in the document or in an include somwhere.

Chris.

Indifference will be the downfall of mankind, but who cares?
 
This is where I located Option Explicit in
"dbconn.asp":

<% Option Explicit %>
<%
Dim objConn
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "Driver={SQL Server};" &_
"Server=xxx;" &_
"Database=xxx;" &_
"Network=DBMSSOCN;" &_
"Uid=xxx;" &_
"Pwd=xxx;"
%>

And everytime my pages have to work with database
<!--#include virtual="/includes/dbconn.asp"--> is added on top of the pages.

I see what ChrisHirst suggested and renamed the Dim(s). Error is still pointing to that specific area.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top