The following code was provided by a book that I am using. I want to learn how each statement works first before jumping into a application.
In ASP pg 1 a dropdown box is dynamically populated and a user will select a store id
Error on ASP pg 2
Procedure 'CountStoreQty' expects parameter '@stor_id', which was not supplied.
asp, line 65
ASP pg. 1
<%
Dim sSQL
Dim cmd
Dim stor_id 'param 1
Dim qty ' param 2 output
'Create a connection object
Set cmd = Server.CreateObject("ADODB.Command")
Set stor_id = Server.CreateObject("ADODB.Parameter")
Set qty = Server.CreateObject("ADODB.Parameter")
'Use a session level connection object -- cn
Set cmd.ActiveConnection = cn
cmd.CommandType = adCmdStoredProc
cmd.CommandText = "CountStoreQty"
stor_id.Direction = adParamInput
stor_id.Type = adChar
stor_id.Size = 4
cmd.Parameters.Append stor_id
qty.Direction = adParamOutput
qty.Type = adInteger
qty.Size = 4
cmd.Parameters.Append qty
Set Session("SP1") = cmd
%>
ASP pg 2
<%
Dim cmd
Dim pm
Dim fld
Dim sStor_ID
'Get the Server and Login information from form1
sStor_Id = Request.Form("selectID")
set cmd = Session("SP1")
'Set the parameter value
cmd.Parameters(1).Value = sStor_ID
'Setup the input parameter
Set rs = cmd.Execute <<<<<<<<line 65
'Display the returned value
%>
The total quantity of sales for <%=sStor_Id %> is <%=cmd.Parameters(1).Value %>
Stored procedure:
CREATE PROC CountStoreQty(@stor_id CHAR(4), @qty INT OUTPUT)
as SELECT @qty = SUM(qty)
FROM sales
WHERE stor_id = @stor_id
GO
In Query Analyzer the error is: procedure expects the parameter @Qty which is not supplied
Thank you in advance for the help!
In ASP pg 1 a dropdown box is dynamically populated and a user will select a store id
Error on ASP pg 2
Procedure 'CountStoreQty' expects parameter '@stor_id', which was not supplied.
asp, line 65
ASP pg. 1
<%
Dim sSQL
Dim cmd
Dim stor_id 'param 1
Dim qty ' param 2 output
'Create a connection object
Set cmd = Server.CreateObject("ADODB.Command")
Set stor_id = Server.CreateObject("ADODB.Parameter")
Set qty = Server.CreateObject("ADODB.Parameter")
'Use a session level connection object -- cn
Set cmd.ActiveConnection = cn
cmd.CommandType = adCmdStoredProc
cmd.CommandText = "CountStoreQty"
stor_id.Direction = adParamInput
stor_id.Type = adChar
stor_id.Size = 4
cmd.Parameters.Append stor_id
qty.Direction = adParamOutput
qty.Type = adInteger
qty.Size = 4
cmd.Parameters.Append qty
Set Session("SP1") = cmd
%>
ASP pg 2
<%
Dim cmd
Dim pm
Dim fld
Dim sStor_ID
'Get the Server and Login information from form1
sStor_Id = Request.Form("selectID")
set cmd = Session("SP1")
'Set the parameter value
cmd.Parameters(1).Value = sStor_ID
'Setup the input parameter
Set rs = cmd.Execute <<<<<<<<line 65
'Display the returned value
%>
The total quantity of sales for <%=sStor_Id %> is <%=cmd.Parameters(1).Value %>
Stored procedure:
CREATE PROC CountStoreQty(@stor_id CHAR(4), @qty INT OUTPUT)
as SELECT @qty = SUM(qty)
FROM sales
WHERE stor_id = @stor_id
GO
In Query Analyzer the error is: procedure expects the parameter @Qty which is not supplied
Thank you in advance for the help!