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!

Stored Proc Parameter Conversion Error

Status
Not open for further replies.

Merkaba

Programmer
Jun 14, 2005
69
US
hi all!

i'm fixing bugs in an ASP web app that tracks employees skills for use in the field. The app calls a Stored Procedure, but when I checked the database, it didn't exist; it must have been lost somewhere. Sooo, I have to Create this Proc over. It is called like this:

Code:
SelectSql = "EXECUTE Skills_SEARCH @skillList = '" & _
            skills_array & "', @Project_ID = '" & _
            project_id & "'"

set get_employees = GetRS(SelectSql)

now skills_array = '1, 2, 3, 4...' or any array of skills id as a STRING. the Proc I made looks like this:

Code:
create procedure Skills_SEARCH
       @skillList as varchar(75)
       @project_id as int
as

SELECT u.id, u.first_name, u.last_name, s.user_id,
COUNT_BIG(s.skill_id) AS NoOfSkills from _users u 
LEFT JOIN _user_skills s ON s.user_id = u.id
LEFT JOIN PT_Project_Skills ps ON s.skill_ID = ps.skill_id
LEFT JOIN PT_Projects p ON ps.project_id = p.project_id
WHERE s.skill_id IN (@skillList) 
AND p.project_id = @project_id
GROUP BY u.id, u.first_name, u.last_name, s.user_id
ORDER BY NoOfSkills desc, u.last_name, u.first_name

Now, if I call the Proc from the ASP page I get the error:

Cannot convert type varchar to type int

Only when there is more than one element in the skill_array
The Proc works fine when one skill is picked, but as soon as the @skillList becomes a string array, it generates errors. I tried a bunch of different data types for @skillList, but none work right. sql_variant type won't generate errors, but it returns an empty recordset. If I manually type
Code:
...WHERE s.skill_id IN (1, 2, 3, 4)...
in Query Analyzer, it works fine. I'm thinking the only way to do this is to dynamically create the SQL statement based on the UBound of the String Array, but I have a feeling the stored proc has to work, cause someone before me had it working with a String Array going into a parameter on a stored proc. I was trying to use CAST in the statement but couldn't get that to work right either. Any Thoughts/Ideas????

Thanks.

Bob


 
oops, forgot to check the FAQs first... I searched the forum for Array but got nothing, so i figured it didn't exist yet. Anyways, Thanks A Ton!

Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top