Solved

expects parameter '@ind_id', which was not supplied.

Posted on 2006-11-20
6
7,841 Views
Last Modified: 2011-08-18
Hi All,

Trying to get my first stored procedure to work. I attempted to use microsoft's "best practices" for it, but no success so far.

Here's the stored procedure:

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go

ALTER PROC [dbo].[rp_ind_year_end]
@ind_id integer
AS
SELECT     report.rp_year_end
FROM         report INNER JOIN
                      category ON report.rp_category = category.ct_id
WHERE     (category.ct_ind = @ind_id)
GROUP BY report.rp_year_end
ORDER BY report.rp_year_end DESC

Here's the code:

                                           Set cn = Server.CreateObject("ADODB.Connection")
                                 cn.Open "Driver={SQL Server};" & _
                                             "Server=(local);" & _
                                             "Database=KlineGroup;" & _
                                             "Trusted_Connection=yes"
                                 Set cmd = Server.CreateObject("ADODB.Command")
                                 Set cmd.ActiveConnection = cn
                                 cmd.CommandText = "rp_ind_year_end"
                                 cmd.CommandType = adCmdStoredProc
                                 cmd.Parameters.Append cmd.CreateParameter("ind_id", adInteger, adParamReturnValue)
                                 ' Set value of Param0 of the default collection to 1
                                 cmd("Param0") = 1
                                 cmd.Execute
                                 rp_year_end = cmd("rp_year_end")

Here's the error:

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC SQL Server Driver][SQL Server]Procedure or Function 'rp_ind_year_end' expects parameter '@ind_id', which was not supplied.

/reports/reports_agpesticides_dynamic.asp, line 66

Line 66 being: rp_year_end = cmd("rp_year_end")

I'm just not sure how to get the value out I guess. Thanks!
0
Comment
Question by:bsowards
  • 3
  • 3
6 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17980872
this should work better:
dim p as adodb.param
set p = cmd.CreateParameter("ind_id", adInteger, adParamInput)
cmd.Parameters.Append p
p.value = 1

cmd.Execute
0
 

Author Comment

by:bsowards
ID: 17980881
how do i get the field?
0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 17980883
also, replace this:
 cmd.Execute
 rp_year_end = cmd("rp_year_end")

by this:

 dim r as adodb.recordset
 set r = cmd.excute
 if r.eof and r.bof then
   'no records:
 else
   rp_year_end = r.fields("rp_year_end").value

 end if  
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17980885
or... by using an output parameter...
0
 

Author Comment

by:bsowards
ID: 17980899
Got an error:

Microsoft VBScript compilation  error '800a0401'

Expected end of statement

/reports/reports_agpesticides_dynamic.asp, line 58

dim p as adodb.param
0
 

Author Comment

by:bsowards
ID: 17980956
The Final, ASP friendly version is:

Set cn = Server.CreateObject("ADODB.Connection")
                                 cn.Open "Driver={SQL Server};" & _
                                             "Server=(local);" & _
                                             "Database=KlineGroup;" & _
                                             "Trusted_Connection=yes"
                                 Set cmd = Server.CreateObject("ADODB.Command")
                                 Set cmd.ActiveConnection = cn
                                 cmd.CommandText = "rp_ind_year_end"
                                 cmd.CommandType = adCmdStoredProc
                                
                                 dim p, rr
                                    set p = cmd.CreateParameter("ind_id", adInteger, adParamInput)
                                    cmd.Parameters.Append p
                                    p.value = 1
                                     set rr = cmd.execute
                                     if rr.eof and rr.bof then
                                       'no records:
                                     else
                                       rp_year_end = rr.fields("rp_year_end").value
                                    
                                     end if  
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Programatically edit Web.config 8 29
How to setup a password to enter my web page? 3 104
RSS Feed Validation 2 59
Visitor to Web site (Log showing Strange IP Address) 9 87
Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

911 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now