Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dire need of help with stored procedure output parameters ( ASP, ODBC)

Status
Not open for further replies.

TheJFM

Programmer
Jun 13, 2002
65
GB
Hello people

Here’s the problem.

ASP Page. Connection to SQL 2000 databases using ODBC connectivity.

Calling stored procedure:

CREATE PROCEDURE sp_mySp @HowMany int OUTPUT AS

select * from my_view
where BALANCE < 0

set @HowMany =@@RowCount



How do I call this stored procedure from the ASP page?

I have tried the following and variations on the theme but I get the following error
'Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.'


set NewdbObj=server.createObject(&quot;ADODB.connection&quot;)

NewdbObj.open session(&quot;myCONNECTION&quot;)

set cmd=server.createObject(&quot;ADODB.command&quot;)

cmd.ActiveConnection = NewdbObj

cmd.CommandText = &quot; sp_mySp &quot;

cmd.Parameters.Append cmd.CreateParameter(&quot;@HowMany&quot;, adInteger, adParamOutput)

cmd.Execute

NewdbObj.close




A helping hand here would be very appreciated


 
ok after re-reading it the first part (stored procedure change) is optional

change

select * from my_view
where BALANCE < 0

set @HowMany =@@RowCount

in the SP to

select @HowMany = Count(*)
from my_view
where BALANCE < 0


the ado code looks fine, except maybe specifying adParamInputOutput instead.

change this :

cmd.Execute

NewdbObj.close

to

dim nHowMany
cmd.Execute
nHowMany = cmd.Parameters(&quot;@HowMany&quot;).value
NewdbObj.close

--
nHowMany not has your answer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top