Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Classic ASP: Error When trying to insert values (scores) on a SQL database

Posted on 2008-10-16
10
Medium Priority
?
237 Views
Last Modified: 2012-06-27
I have a admin page in which i want to enter the scores for a given Golfer and store this on a sql database .
When I enter the score for all 18 holes , it does it correctly, but when i choose front 9 or back 9 , it show me an error message.
<%
dim colorTee
dim showThis
if request("radTee")="" then 
%>
<script language=vbs>
 msgbox("Please Select an Option")
 history.go(-1)
</script>		
<%
end if
colorTee = mid(request("radTee"),1, len(request("radTee"))-2)
showThis = mid(request("radTee"), len(request("radTee"))-1, 2)
 
set rs = Server.CreateObject("ADODB.Recordset")
sql = "SELECT * from CourseHoles WHERE CourseID = " & Cint(request("hidCourseID")) & "AND Difficulty = '" & colorTee & "'"
 
rs.Open sql, conSQL
if not rs.EOF then rs.movefirst
 
dim yardsOUT
dim yardsIN
dim totalYards
 
yardsOUT=0
yardsIN=0
yardsOUT = rs("h1") + rs("h2") + rs("h3") + rs("h4") + rs("h5") + rs("h6") + rs("h7") + rs("h8") + rs("h9")
yardsIN = rs("h10") + rs("h11") + rs("h12") + rs("h13") + rs("h14") + rs("h15") + rs("h16") + rs("h17") + rs("h18")
 
totalYards = yardsOUT + yardsIN 
 
set rs2 = Server.CreateObject("ADODB.Recordset")
sql2 = "SELECT * from CourseHoles WHERE CourseID = " & Cint(request("hidCourseID")) & "AND Difficulty = 'Par'"
rs2.Open sql2, conSQL
if not rs2.EOF then rs2.movefirst
 
dim totalPar
totalPar = int(request("hidFrontPar")) + int(request("hidBackPar"))
 
%>

Open in new window

0
Comment
Question by:RickyGtz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
10 Comments
 
LVL 4

Expert Comment

by:rhodesb
ID: 22733742
Do you get the errors when you run an 'INSERT' statement?  I don't see any INSERT statements in your code above.  If the error is occurring on an insert statement, then likely you are inserting black data into fields that are set to 'required' or something similar.  Change the properties of the fields that store the data for the back 9 to not be required fields and you won't have the error anymore.

Also, in order not to waste server resources, any objects that you create and/or open should be closed and/or destroyed when you are done using them as ASP does not have automatic garbage collection.  If you don't then the object will still be on the server once your page has output and the resources won't free up until they time out (usually 20 minutes).  So after you are finished using your recordset objects, they should be destroyed:
rs.close
set rs = nothing
rs2.close
set rs2 = nothing
0
 

Author Comment

by:RickyGtz
ID: 22742143
This is the full code where I get the error '80020009'


<% level="../../"%>
<!-- #include file="../logincheck.asp"-->
<!--#include file="../include/intialize.inc"-->
<!--include file="../include/connection.asp"-->
<!--#include file="../../../Connections/sqlConn1.asp" -->
 
<%
dim colorTee
dim showThis
if request("radTee")="" then 
%>
<script language=vbs>
 msgbox("Please Select an Option")
 history.go(-1)
</script>		
<%
end if
colorTee = mid(request("radTee"),1, len(request("radTee"))-2)
showThis = mid(request("radTee"), len(request("radTee"))-1, 2)
 
set rs = Server.CreateObject("ADODB.Recordset")
sql = "SELECT * from CourseHoles WHERE CourseID = " & Cint(request("hidCourseID")) & "AND Difficulty = '" & colorTee & "'"
 
rs.Open sql, conSQL
if not rs.EOF then rs.movefirst
 
dim yardsOUT
dim yardsIN
dim totalYards
 
yardsOUT=0
yardsIN=0
yardsOUT = rs("h1") + rs("h2") + rs("h3") + rs("h4") + rs("h5") + rs("h6") + rs("h7") + rs("h8") + rs("h9")
yardsIN = rs("h10") + rs("h11") + rs("h12") + rs("h13") + rs("h14") + rs("h15") + rs("h16") + rs("h17") + rs("h18")
 
totalYards = yardsOUT + yardsIN 
 
set rs2 = Server.CreateObject("ADODB.Recordset")
sql2 = "SELECT * from CourseHoles WHERE CourseID = " & Cint(request("hidCourseID")) & "AND Difficulty = 'Par'"
rs2.Open sql2, conSQL
if not rs2.EOF then rs2.movefirst
 
dim totalPar
totalPar = int(request("hidFrontPar")) + int(request("hidBackPar"))
 
%>
 
<html>
<head>
<title><%=PageTitle%></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="../style/style.css" rel="stylesheet" type="text/css">
</head>
<script language="VBScript">
	sub cmdBack_OnClick
		document.location = "viewScores.asp"
	end sub
</script>

Open in new window

0
 
LVL 4

Expert Comment

by:rhodesb
ID: 22742168
Does it give you a line number for the error?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:RickyGtz
ID: 22743033
No, only
error '80020009'
0
 
LVL 4

Expert Comment

by:rhodesb
ID: 22744207
Before I continue looking for something more difficult, fix the missing # sign on the include in line 4 just to make sure that isn't causing the problem.  I doubt that will fix it but just to be sure.
0
 

Author Comment

by:RickyGtz
ID: 22744284
oh thats just html commented old connection,
0
 
LVL 4

Expert Comment

by:rhodesb
ID: 22744348
Right.  Sorry, I'm an idiot.
0
 
LVL 4

Expert Comment

by:rhodesb
ID: 22744719
I've looked carefully over your code and I see nothing apparently wrong with any of it.  Here is my next suggestion, which is a bit of pain but shouldn't take too long.
Comment out all of your ASP code starting on line 24.  Uncomment the lines 1 at a time, running the script after each time until you find the line that seems to cause the error.  This should help point us in the right place to look.
0
 

Author Comment

by:RickyGtz
ID: 22744857
apparently this lines are the ones are causing  the error:

yardsOUT = rs("h1") + rs("h2") + rs("h3") + rs("h4") + rs("h5") + rs("h6") + rs("h7") + rs("h8") + rs("h9")
yardsIN = rs("h10") + rs("h11") + rs("h12") + rs("h13") + rs("h14") + rs("h15") + rs("h16") + rs("h17") + rs("h18")
0
 
LVL 4

Accepted Solution

by:
rhodesb earned 1500 total points
ID: 22744956
You said before that the problem only occurs when 9 holes are entered and not 18.  Maybe the error is caused by trying to add null values to each other or by trying to add null values to a variable that is a numeric type (yardsIN and yardsOut would both be numeric because you set them both to be equal to zero).  Do a check to prevent adding null values and see if that helps.
If NOT isNull(rs("h1")) Then
   yardsOUT = rs("h1") + rs("h2") + ... + rs("h9")
End If
If NOT isNull(rs("h10")) Then
   yardsIN = rs("h10") + ... + rs("h18")
End If

Open in new window

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question