Plz help: Problem with stored proc

New2VB
04-18-2004, 06:20 AM
I have a stored proc in MS SQL Server 2000:

CREATE PROCEDURE spBCountSub
@Cnt int output ,
@SubC char(2)
as
SELECT @Cnt=COUNT(tblB4.Code)
FROM tblB4 INNER JOIN
tblB1 ON tblB4.Code = tblB1.Code
WHERE tblB1.SubC = @SubC
GO

but when i want to execute this by a command object, i get the following error: -2147217900
formal parameter '@SubC' was defined as OUTPUT but the actual parameter not declared OUTPUT

but i defined tha param as:

Set pSubC = cmd.CreateParameter("SubC", adChar, adParamInput, 2) cmd.Parameters.Append pSubC

plz help.

TheDutch IceMan
04-18-2004, 08:31 AM
When using output parameters you have to start (in your recordset declaration) with the output parameter
Below an example!
Say that you work with an objComm


With ObjComm
.CommandText = "yourStoredProcName"
.CommandType = adCmdStoredProc
Set .ActiveConnection = objConn
.parameters.Append .CreateParameter("Cnt", adInteger, adParamOutput)
.parameters.Append .CreateParameter("SubC", adChar, adParamInput, 2)
.Execute Options:=adExecuteNoRecords
End With

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum