Error converting data type nvarchar to int
I've got a very simple report (using Employees table in Northwind) that I'm using an INT (EmployeesID) as the parameter. (Query Failed for Dataset1) it works fine if I choose only one item from the list - but I'm allowing Multiple values, but when I actually choose multiple values, I get the error that's in the subject line. My sProc to get the Employees from the ManagerID (which is actually the EmployeeID - list of employees) .Here's the code: Select Emp.EmployeeID, emp.Firstname + ' ' + emp.Lastname as Name, emp.Extension, emp.reportsto,mgrs.FirstName + ' ' + mgrs.lastname as Manager from Employees emp inner join Employees mgrs on emp.ReportsTo=mgrs.EmployeeID Where emp.ReportsTo=@MgrID I don't see what it means by converting nvarchar to int -- ReportsTo field and the EmployeeID field are both int the Listbox query Value field is EmployeeID and label field is the manager name. the only thing I can think of is that, when it runs the query, it's using the combination of the names as the search criteria, instead of the employeeID for each name. Can anyone see what might be the problem?
November 19th, 2010 12:32pm

Hello, If you have mulitple values for a parameter, you can't compare it with =, you have to use the IN operator, and this works also with only one single value: Where emp.ReportsTo IN (@MgrID) Olaf Helper ----------- * cogito ergo sum * errare humanum est * quote erat demonstrandum * Wenn ich denke, ist das ein Fehler und das beweise ich täglich http://olafhelper.over-blog.de
Free Windows Admin Tool Kit Click here and download it now
November 19th, 2010 12:50pm

Tried that - - it still didn't work Any other ideas on why it doesn't work?
November 19th, 2010 12:53pm

I've found a strange anomaly. the query I was using that did not work was a stored procedure (using the 'in' syntax) I copied the query itself from the sproc, deleted the old dataset and parameter, and then created a new dataset, pasted in the query, set up the parameter just like before. Low and behold - - it worked! One strange thing I noticed (even though I'm not checking the checkbox), is that the 'allow blanks' was not enabled when I was using the stored procedure, but it is enabled, when I use a regular built in query. And, of course, the datatype is automatically set to text..... Like I said, I have no need for using that checkbox, so it really doesn't matter - just noticed it and thought all this was a bit strange. (I still got the error when trying to use the SProc and setting the datatype to text.) Why did it not work from a stored procedure?
Free Windows Admin Tool Kit Click here and download it now
November 19th, 2010 3:02pm

Hi AugustWind, To solve this issue, check this http://blog.summitcloud.com/2010/01/multivalue-parameters-with-stored-procedures-in-ssrs-sql/ on how to use MultiValue Parameters with Stored Procedures in SSRS. thanks, Jerry
November 22nd, 2010 12:44am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics