Hi
I have create my report and it's bind to an SQL stored procedure - it works fine when I was pass single value - but now I need to pass multivlue (ProductID) as example to get report where ProductID in (1,2,3)
I set the SQL stored procedure to let me get result as i need - but the problem i got is in my report i got err msg in image in attachment
so please how can i make it work in MVC Project or HTML5 Project i can't find that in demo files examples?
Thanks a lot ....
Stored Code:
@MultiVal NVARCHAR(
MAX
),
@qty
INT
AS
SELECT
ProductID, ProductName, @qty
AS
stock
FROM
Products
CROSS
APPLY dbo.NumbersTable(1, @qty, 1)
WHERE
ProductID
IN
(
SELECT
Val
FROM
dbo.fn_String_To_Table(@MultiVal,
','
,1))
fn_String_To_Table FUN :
ALTER
FUNCTION
[dbo].[fn_String_To_Table] (
@String
VARCHAR
(
max
), /* input string */
@Delimeter
char
(1), /* delimiter */
@TrimSpace
bit
) /* kill whitespace? */
RETURNS
@
Table
TABLE
( [Val]
VARCHAR
(4000) )
AS
BEGIN
DECLARE
@Val
VARCHAR
(4000)
WHILE LEN(@String) > 0
BEGIN
SET
@Val =
LEFT
(@String,
ISNULL
(
NULLIF
(CHARINDEX(@Delimeter, @String) - 1, -1),
LEN(@String)))
SET
@String =
SUBSTRING
(@String,
ISNULL
(
NULLIF
(CHARINDEX(@Delimeter, @String), 0),
LEN(@String)) + 1, LEN(@String))
IF @TrimSpace = 1
Set
@Val = LTRIM(RTRIM(@Val))
INSERT
INTO
@
Table
( [Val] )
VALUES
( @Val )
END
RETURN
END