Advertisement

07.15.2008 at 08:12PM PDT, ID: 23568405
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

6.8

Getting error message while running ASP pages

Asked by WoolfStephen in Active Server Pages (ASP)

Tags: , ,

I am learning classic ASP development. I have two simple pages, Default.asp, and InsertTest.asp. The Default.asp page has a single drop-down list which pulls states from a SQL Server 2005 database table, and also four check boxes.
The InsertTest.asp page collects the information from the Default.asp form and is suppossed to insert the values into a local SQL Server Express 2005 database table, hosted on a local machine which is running Windows Server 2003 standard edition and SQL Server Express 2005.
I have enabled error catching in the InsertTest.asp page.
The InsertTest.asp page is suppossed to collect the form values, create the parameters for my stored procedure, and call the stored procedure to insert the parameters into the table.
My table is a follows:
ID int, not null, is identity
StateID, int, not null
Spring, bit
Summer, bit
Fall, bit
Winter, bit

My stored procedure is as follows:
USE [Questionairre]
GO
/****** Object:  StoredProcedure [dbo].[new_Season_Rec]    Script Date: 07/11/2008 21:27:26 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[new_Season_Rec]
                     @stateID int,@spring bit,@summer bit,@fall bit,@winter bit
AS
BEGIN
      SET NOCOUNT ON;
    -- Insert statements for procedure here
      INSERT INTO      Seasons(StateID,Spring,Summer,Fall,Winter)
      VALUES(@stateID,@spring,@summer,@fall,@winter)            
END

My two pages are below:Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
First Page
------------------------------------------------------------------------
<html>
<head>
<title>Classic ASP in Action
</title>
</head>
<body>Which state do you live in?<br/><br/>
<form method="post" action="InsertTest.asp">
 
<select name="stateID">
		<%
		'open DB
		Dim conn
		Dim sql
		Dim rs
		Dim strState
		Dim strStateName
		Dim intStateID
		set conn=createobject("ADODB.Connection")
		conn.ConnectionString = "Provider=SQLOLEDB; Data Source=********; Initial Catalog=********; User ID=********; Password=********;"
		conn.open
				
		'retrieve dropdown menu contents
		sql = "SELECT ID,Description,Name FROM LUStates ORDER BY Description"
		set rs = conn.execute(sql)
		'populate dropdown
		Do Until rs.EOF
		intStateID = rs("ID").value
		strState = rs("Description")
		strStateName = rs("Name")%>
		<Option value="<%=intStateID%>"><%=strState%> - <%=strStateName%></OPTION>
		<%
		rs.MoveNext
		Loop
		'kill off recordset object
		Set rs = Nothing
		conn.close
		%>
	</select><br/><br/>
Which seasons of the year do you like?<br/><br/>
<input type="checkbox" name="spring" value="1">&nbsp;Spring<br/><br/>
<input type="checkbox" name="summer" value="1">&nbsp;Summer<br/><br/>
<input type="checkbox" name="fall" value="1">&nbsp;Fall<br/><br/>
<input type="checkbox" name="winter" value="1">&nbsp;Winter<br/><br/><br/>
<input type="submit" value="submit" text="submit"/>
</form>
</body>
</html>
 
Second Page
------------------------------------------------------------------------
<html>
<head>
<title>InsertTest.asp</title>
</head>
<body bgcolor="#FFFFFF">
<%
stateID = Request("stateID")
If Request("spring") = 1 Then
	spring = 1
Else
	spring = 0
End If
If Request("summer") = 1 Then
	summer = 1
Else
	summer = 0
End If
If Request("fall") = 1 Then
	fall = 1
Else
	fall = 0
End If
If Request("winter") = 1 Then
	winter = 1
Else
	winter = 0
End If
'Dimension Variables used during the database connection 
	Dim conn, strServer, strDatabase, strLogin, strPass,cmd
	strServer = "SERVER1\SQLEXPRESS"
	strDatabase = "Questionairre"
	strLogin = "********"
	strPass = "********"
 
Set conn = Server.CreateObject("ADODB.Connection")
'Open a connection
conn.ConnectionString = "PROVIDER=SQLOLEDB" & _					";Server=" & strServer & _
			";UID=" & strLogin & _					";PWD=" & strPass & _					";Database=" & strDatabase
conn.open
 
 
on error resume next
'Call the SP to create a NEW record in the Seasons table
	Set cmd = Server.CreateObject("ADODB.Command")
	With cmd
		.ActiveConnection = conn
		.CommandText = "new_Season_Rec"
		.CommandType = adCmdStoredProc
		.Parameters.Append .CreateParameter("@ret", adInteger, adParamReturnValue)
		.Parameters.Append .CreateParameter("@stateID", adinteger, adParamInput, stateID)
		.Parameters.Append .CreateParameter("@spring", adBoolean, adParamInput,1, spring)
		.Parameters.Append .CreateParameter("@summer", adBoolean, adParamInput,1, summer)
		.Parameters.Append .CreateParameter("@fall", adBoolean, adParamInput,1, fall)
		.Parameters.Append .CreateParameter("@winter", adBoolean, adParamInput,1, winter)
 
 
			.Execute
 
	End With
 
'Verify that the SP did not return an errors; If it did, sent them to an error page explaining what happened.
	If cmd("@ret") <> 0 OR cmd.ActiveConnection.Errors.Count <> 0 Then
	If conn.errors.count > 0 then
		'Response.Clear
		Response.Write"<script language='JavaScript'>" & vbNewLine
		Response.Write"alert(" & chr(34) & conn.errors(0).description & chr(34) & ");" & vbNewLine
		Response.Write"</script>" & vbNewLine
		'Response.End
	End If
	End If
 
If err.number>0 then
   response.write "VBScript Errors Occured:" & "<P>"
   response.write "Error Number=" & err.number & "<P>"
   response.write "Error Descr.=" & err.description & "<P>"
   response.write "Help Context=" & err.helpcontext & "<P>" 
   response.write "Help Path=" & err.helppath & "<P>"
   response.write "Native Error=" & err.nativeerror & "<P>"
   response.write "Source=" & err.source & "<P>"
   response.write "SQLState=" & err.sqlstate & "<P>"
else
   response.write "No VBScript Errors Occured" & "<P>"
end if
IF conn.errors.count> 0 then
    response.write "Database Errors Occured" & "<br>"
    response.write "<b>" & cmd & "</b><P>"
    for counter= 0 to conn.errors.count
        response.write "Error #" & conn.errors(counter).number & "<P>"
        response.write "Error desc. -> " & conn.errors(counter).description & "<P>"
    next
else
   response.write "No Database Errors Occured!" & "<P>"
end if
Conn.Close
set conn=nothing
 
Response.Write "state = " & stateID & "<br/>"
Response.Write "spring = " & spring & "<br/>"
Response.Write "summer = " & summer & "<br/>"
Response.Write "fall = " & fall & "<br/>"
Response.Write "winter = " & winter & "<br/>"
%>
</BODY>
</HTML>
------------------------------------------------------------------------
The following is the output I get back:
VBScript Errors Occured:
Error Number=3265
 
Error Descr.=Item cannot be found in the collection corresponding to the requested name or ordinal.
 
Help Context=1240649
 
Source=Microsoft VBScript runtime error
 
No Database Errors Occured!
 
state = 4
spring = 0
summer = 1
fall = 0
winter = 0
 
If I execute the stored procedure form SQL Server Management Studio, it works fine. It appears as though the Requests are not working for the parameters, although I can do Write.Responses and get the correct values.
 
 
[+][-]07.15.2008 at 10:07PM PDT, ID: 22013372

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.16.2008 at 07:23AM PDT, ID: 22016191

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.16.2008 at 07:50AM PDT, ID: 22016484

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.16.2008 at 12:09PM PDT, ID: 22019075

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.16.2008 at 03:18PM PDT, ID: 22020715

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.16.2008 at 09:26PM PDT, ID: 22022355

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.17.2008 at 05:47AM PDT, ID: 22024760

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.17.2008 at 06:59PM PDT, ID: 22032342

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.22.2008 at 07:06AM PDT, ID: 22059469

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.23.2008 at 03:37AM PDT, ID: 22067673

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.24.2008 at 06:18AM PDT, ID: 22078749

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.30.2008 at 01:32PM PDT, ID: 22124536

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Active Server Pages (ASP)
Tags: Classic ASP, Internet Explorer, Error Number=3265 Item cannot be found in the collection corresponding to the requested name or ordinal.
Sign Up Now!
Solution Provided By: WoolfStephen
Participating Experts: 2
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628