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!

ASP and SQL stored procedure - too many arguments

Status
Not open for further replies.

lasers

Technical User
Oct 24, 2007
12
I have a SQL stored procedure like this:
Code:
CREATE PROCEDURE [dbo].[myStoredProc]
@NameList varchar(5000)
as
select * from dbo.MyTable
where UserName in (@NameList)
go

In my asp page I have this code:
Code:
nameList = "'john','mary','sue','dave'"

rs.open "exec myStoredProc " & nameList, dCon

I get this error:
Procedure or function myStoredProc has too many arguments specified.

What am I doing wrong? I'm assuming it has something to do with the way I pass the parameter to the stored proc.

 
lasers,
You are correct, SQL Server is seeing the single quotes around your nameList values, separated by comma's, as individual prameters rather than a single list.

You will need to either remove them - as per or escape them so that it passes through correctly.

You should see the same issue if you run the SQL inside SQL Server.

Greg Griffiths
Livelink Certified Developer & ECM Global Star Champion 2005 & 2006
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top