sql server stored procedure

Procedure expects parameter

Page 1 of 1

2 Replies - 6038 Views - Last Post: 09 May 2002 - 12:27 PM

#1 George Pryor   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 23-April 02

sql server stored procedure

Posted 24 April 2002 - 12:07 AM

I am a programming student and when I run this code I get the following error message, I have tried several variations on calling this stored procedure and nothing works so far. Any help would be greatly appreciated.

here is page 1 code:

<%@ Language=VBScript %>
<% option explicit %>

<%
Dim conn
Dim SQL
Dim R
Dim F
Dim RecsAffected
dim cm, param
dim selGrade
dim stid
'SQL = "SELECT * FROM Students ORDER BY LastName, FirstName"

if Request.Form("submit1") = "Submit" and  Request.Form("selGrade") <> "Select Grade" then
selGrade = Cint(Request.Form("selGrade"))
Set conn = Server.CreateObject("ADODB.Connection")
conn.Mode = adModeRead
conn.ConnectionString = Application("Conn_ConnectionString")
conn.CursorLocation=adUseClient
conn.open

set cm = Server.CreateObject("ADODB.Command")
cm.ActiveConnection = conn
set param = cm.CreateParameter("Grade", adInteger, adParamInput, 4, selGrade)
cm.Parameters.Append param

cm.CommandText = "getStudentsForGrade"
cm.CommandType=adCmdStoredProc
set R = cm.Execute
else
Set conn = Server.CreateObject("ADODB.Connection")
conn.Mode = adModeRead
conn.ConnectionString = Application("Conn_ConnectionString")
conn.CursorLocation=adUseClient
conn.open
set cm = Server.CreateObject("ADODB.Command")
cm.ActiveConnection = conn
cm.CommandText = "getAllStudents"
cm.CommandType = adCmdStoredproc
Set R = cm.Execute
end if


%>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY bgColor=khaki>
<H3><B>Students</B></H3>
<FORM action="GPryor_2L1.asp" method=POST name=form1>
<TABLE Border=1 Cellspacing=1 Cellpadding=1>
<TR>
<SELECT name=selGrade>
<OPTION>Select Grade</OPTION>
<OPTION>1</OPTION>
<OPTION>2</OPTION>
<OPTION>3</OPTION>
</SELECT></TD>
</TR>
<BR>
<INPUT type="submit" value="Submit" id=submit1 name=submit1>
</FORM>
<%
R.MoveFirst
Response.Write "<table align='left' border='1'>"
Response.Write "<tr>" & vbcrlf
Response.Write "    <td align=center>StudentID</td>" & vbcrlf
Response.Write "    <td>Grade</td>" & vbcrlf
Response.Write "    <td>First Name</td>" & vbcrlf
Response.Write "    <td>Last Name</td>" & vbcrlf
Response.Write "</tr>" & vbcrlf
do while not R.EOF
Response.Write "<tr>" & vbcrlf
Response.Write "    <td align=center><a href='GPryor_2L2.asp?stid=" & R("StudentID").value & "'>"
Response.Write R("StudentID").value & "</a></td>" & vbcrlf
Response.Write "    <td align=center>" & R("Grade").value & "</td>"
Response.Write "    <td>" & R("FirstName").value & "</td>" & vbcrlf
Response.Write "    <td>" & R("LastName").value & "</td>" & vbcrlf
Response.Write "</tr>" & vbcrlf
R.MoveNext
loop
Response.Write "</table>"
'R.Close
'set R = nothing
'conn.Close
'set conn = nothingg

%>
</BODY>
</HTML>
Here is page 2 code:
<%@ Language=VBScript %>
<% option explicit %>

<%
Dim conn
Dim SQL
Dim RecsAffected
dim R, cm, param
dim stid, lname, fname, grade


if Cint(Request.QueryString("stid")) > 0 then
stid = Cint(Request.QueryString("stid"))
Set conn = Server.CreateObject("ADODB.Connection")
conn.Mode = adModeRead
conn.ConnectionString = Application("Conn_ConnectionString")
conn.CursorLocation=adUseClient
conn.open

set cm = Server.CreateObject("ADODB.Command")
cm.ActiveConnection = conn
set param = cm.CreateParameter("StudentID",adInteger,adParamInput,4,stid)
cm.Parameters.Append param

cm.CommandText = "getStudentForID"
cm.CommandType=adCmdStoredProc
set R = cm.Execute
end if
if Request.Form("submit1") = "Update" then
stid = Cint(Request.Form("StudentID"))
fname = Request.Form("FirstName")
lname = Request.Form("LastName")
grade = cint(Request.Form("Grade"))
Set conn = Server.CreateObject("ADODB.Connection")
conn.Mode = adModeReadWrite
conn.ConnectionString = Application("Conn_ConnectionString")
conn.CursorLocation=adUseClient
conn.open

set cm = Server.CreateObject("ADODB.Command")
cm.ActiveConnection = conn
set param = cm.CreateParameter("StudentID",adInteger,adParamInput,4,stid)
cm.Parameters.Append param
set param = cm.CreateParameter("LastName",adVarChar,adParamInput,20,lname)
cm.Parameters.Append param
set param = cm.CreateParameter("FirstName",adVarChar,adParamInput,50,fname)
cm.Parameters.Append param
set param = cm.CreateParameter("Grade",adInteger,adParamInput,5,grade)
cm.Parameters.Append param

cm.CommandText = "updateStudent"
cm.CommandType=adCmdStoredProc
set R = cm.Execute
end if
if Request.Form("submit3") = "Delete" then
stid = Cint(Request.Form("StudentID"))
Set conn = Server.CreateObject("ADODB.Connection")
conn.Mode = adModeReadWrite
conn.ConnectionString = Application("Conn_ConnectionString")
conn.CursorLocation=adUseClient
conn.open

set cm = Server.CreateObject("ADODB.Command")
cm.ActiveConnection = conn
set param = cm.CreateParameter("StudentID", adInteger, adParamInput, 4, stid)
cm.Parameters.Append param

cm.CommandText = "deleteStudent"
cm.CommandType=adCmdStoredProc
set R = cm.Execute
end if
%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY bgColor=khaki>
<% =SQL %><BR>
<FORM action="GPryor_2L2.asp" method=post name=form1 style="BACKGROUND-COLOR: khaki">
<TABLE BORDER=1 CELLSPACING=1 CELLPADDING=1>
<TR>
<TD colspan="2" align=middle><STRONG>Update Student Records</STRONG></TD>
</TR>
 <TR>
   <TD><STRONG>Student ID:</STRONG></TD>
   <TD><INPUT style="WIDTH: 42px; HEIGHT: 22px" width="42" size=6
     name=stid readonly value='<% =R("StudentID") %>'></TD></TR>
 <TR>
   <TD><STRONG>First name:</STRONG></TD>
   <TD><INPUT value='<% =R("FirstName") %>'
   name=fname>
    </TD></TD></TR>
<TR>
<TD><STRONG>Last name:</STRONG></TD>
<TD><STRONG><INPUT
     value='<% =R("LastName") %>' name= lname>  
     </STRONG></TD>
</TR>
 <TR>
   <TD><STRONG>Grade:</STRONG></TD>
   <TD><INPUT style="WIDTH: 42px; HEIGHT: 22px" size=6
     value='<% =R("Grade") %>' name=grade> </TD></TR>
<TR>
<TD colspan="2" align=middle>
<STRONG><INPUT type=submit value=Update name=submit1>&nbsp;
<INPUT type=submit value=Add name=submit1>&nbsp;
<INPUT type=submit value=Cancel name=submit2>&nbsp;
<INPUT type=submit value=Delete name=submit3></STRONG></TD>
</TR>
</TABLE>
</FORM>

</BODY>
</HTML>


Is This A Good Question/Topic? 0
  • +

Replies To: sql server stored procedure

#2 SlashRaid   User is offline

  • Dream.In.Force

Reputation: 1
  • View blog
  • Posts: 2,421
  • Joined: 21-January 02

Re: sql server stored procedure

Posted 24 April 2002 - 05:04 AM

Quote

Quote: from George Pryor on 3:12 am on April 24, 2002
Forgot the error message on prvious post, it is :

Error Type:
Microsoft OLE DB Provider for SQL Server (0x80040E10)
Procedure 'updateStudent' expects parameter '@Grade', which was not supplied.
/ADO1/GPryor_2L2.asp, line 53


thanks

Above is the error. George made two posts, so I quoted the error and posted it here so it can be read in context with the question/code.
Was This Post Helpful? 0
  • +
  • -

#3 klewlis   User is offline

  • cur tu me vexas?

Reputation: 8
  • View blog
  • Posts: 1,723
  • Joined: 09-November 01

Re: sql server stored procedure

Posted 09 May 2002 - 12:27 PM

do you know for sure that the Grade variable isn't empty as it's going into the stored procedure? it's looking for a value there and not finding one...


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1