Advertisement
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.
Your Input Matters 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! |
||
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"> Spring<br/><br/>
<input type="checkbox" name="summer" value="1"> Summer<br/><br/>
<input type="checkbox" name="fall" value="1"> Fall<br/><br/>
<input type="checkbox" name="winter" value="1"> 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.
|