Boble343


Maybe I am missing something completely obvious but as far as I can tell I aren't!

I am trying to simply pass a parameter to a stored proc to return results. Easy So I thought so too...

This is my stored procedure below (in it's ALTER PROCEDURE form):

ALTER PROCEDURE [dbo].[spd_Tester]

-- Add the parameters for the stored procedure here

@Check int

AS

BEGIN

SELECT * FROM tblPerson

WHERE PersonID = @Check

END

Now I know this is a SQL Server forum but I figure anyone who reads this probably does some application programming as well, so here is the code that calls this. It's in VBA using Access 2003. I figure the error is being returned from SQL Server Express so that's why I have come to this forum instead of an Access forum! I could be wrong though...

Here is the code that calls this:

Dim rs As ADODB.Recordset
Dim cmd As ADODB.Command

Set cmd = New ADODB.Command

'Run sql command
With cmd
.ActiveConnection = CurrentProject.Connection

.CommandText = "dbo.spd_Tester"
.Parameters.Append .CreateParameter("@Check", adInteger, adParamInput, , Me.txtFirstName)


'Execute, return recordset
Set rs = .Execute

End With

Now I figure this should work. However, I get the error "Procedure or function 'spd_Tester' expects parameter '@Check', which was not supplied." when I execute the procedure with the number 1 in the txtFirstName text box.

Can someone tell me what I am doing wrong The tblPerson table has data in it, if I run the select from a query window, specifying a value for @Check, it works just fine.

Thanks in advance!




Re: Receive "Procedure or function expects parameter..." error unexpectedly

Boble343


As a followup, I have noticed that I don't get the error if I specify a default value for the parameter. So, if I change the parameter part of the stored proc from:

@Check int

to

@Check int = 0

I always get no results, but no error. Very strange.

I have also tested this on a Vista machine running Office 2007 - same result. Leads me to think I am missing some basic piece of information but for the life of me I don't know what it is!






Re: Receive "Procedure or function expects parameter..." error unexpectedly

Boble343

Sorry, will close this, found where I was going wrong. I knew something easy had to be missing!

It was a critical little line of VBA that goes:

.CommandType = adCmdStoredProc

Sorry for wasting your time!

Thanks.