Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 8th, 2011, 07:05 AM
Registered User
 
Join Date: Mar 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Microsoft VBScript error

I'm really sorry but im new to asp. I get this problem every time I try it.

Microsoft VBScript compilation error '800a0411'

Name redefined

/_____13_/jeremiahmojares/listofstudentrecords.asp, line 12

Dim section, SQL
-------------^

Here's the code any help would be greatly appreciated :)

<% Option Explicit %>
<html>
<head>
<title>Student List</title>
</head>

<body>
<h1 align="center">List of Students</h1>

<!--#include file="connect.asp"-->
<%
Dim section, SQL
section=Request.Form("section")
%>
<h2 align="center">Section: <%=section%></h2>

<%
SQL = "select * from students where studsection='"
SQL = SQL & section & "' order by lastname,firstname"
rs.Open SQL, conn
%>

<p align="center">
<table boder="1">
<tr align="center">
<td>STUDENT<br />NUMBER</td>
<td>NAME</td>
<td>GENDER</td>
<td>SECTION</td>
</tr>

<%
While rs.EOF=False
%>
<tr>
<td>
<a href="updatestudentrecord.asp?studnum=<%=rs("studn um")%>">
<%=rs("studnum")%></a>
</td>
<td><%=rs("lastname") & " " & rs("firstname")%></td>
<td><%=rs("gender")%></td>
<td><%=rs("studsection")%></td>
</tr>
<%
rs.MoveNext
Wend
%>
</table>
</p>

<%
rs.Close
set conn = Nothing
%>
</body>
</html>
 
Old March 8th, 2011, 12:06 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

You typically get this error when using an include file that already defines a variable with the same name. Let's say connect.asp contains this code:

Code:
 
Dim SQL
Your current page then contains this:

Code:
 
<!--#include file="connect.asp"-->
Dim section, SQL
When the page is parsed, the include file is placed in the main file, resulting in this code:

Code:
 
Dim SQL
Dim section, SQL
This in turn leads to the error you're getting.

Either use a new variable name, or find out if you really need the SQL variable in the include file.

Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old March 8th, 2011, 12:08 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

BTW: you may want to read a bit on SQL injection and ways to prevent it: http://en.wikipedia.org/wiki/SQL_injection

With your current code, you site is open for attacks, which could lead to loss of data, or worse - loss of control over your server..... ;-(

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old March 9th, 2011, 06:30 AM
Registered User
 
Join Date: Mar 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the help Imar. We only need this for a project in school so I wouldn't need to change the code for security reasons :)
 
Old March 9th, 2011, 08:26 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

It's never too soon to start learning best practices, especially when it comes to security... ;-)

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Microsoft VBScript runtime error '800a000d' error futurehype Classic ASP Professional 20 May 23rd, 2011 10:47 PM
Error: Microsoft VBScript compilation error '800a0409' webXtreme Classic ASP Basics 4 February 4th, 2009 03:58 AM
Microsoft VBScript compilation error karlzoe Classic ASP Databases 2 December 29th, 2004 10:44 AM
Microsoft VBScript compilation error '800a0401' baistopgun BOOK: Beginning ASP 3.0 3 October 16th, 2004 12:52 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.