Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Input and Output parameters with stored procedures

Author  Topic 

filf
Yak Posting Veteran

67 Posts

Posted - 2001-06-15 : 12:11:49
I am having a real problem, I am trying to call a stored procedure with a no of parameters, I then wish to return different parameters as OUTPUT vars to the calling script. I am accessing the stored procedure from a browser so I am using ADO. Here is the prob:
1: Pass no parameters, sql is hardcoded, output var returns what it should.
2. Pass parameters to make sql more dynamic, but don't pass value for the output parameter then recieve the error: sp_sprocname expects parameter @paramName
3. Okay so I try setting the OUTPUT param to a value in the stored proc, then I set this param to the result of a select statement, and I get no output at all.

Here is my stored proc definition:

ALTER PROCEDURE sp_isValidLogon (@email varchar(60),
@password varchar(12),
@playerId integer=0 OUTPUT)
As
Select @playerId=player_id From competitor where email = @email and password = @password
Go

Here is my call to the stored proc via ADO:
Set cmd = Server.CreateObject("ADODB.Command")
cmd.CommandText = "sp_IsValidLogon '"&strUserName&"','"&strPassword&"'"
set pplayerId = cmd.CreateParameter("playerId", adInteger, adParamOutput)
cmd.ActiveConnection = objConn
cmd.Parameters.Append pplayerId
cmd.Execute
If someone could explain where I am going wrong I would really appreciate it because i have been playing with this all afternoon to no avail. I even tried declaring playerId seperately but you can't declare an output var.Schucks.Please Help a newbie.


   

- Advertisement -