Solved

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

Posted on 2006-11-20
6
7,836 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

When you work with shopping cart / ecommerce relates web sites, you need to pass the certain form post details to the payment gateway process page with required details for the products items you give to order. Also you may need to track the ordered…
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
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…

707 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