This is a migrated thread and some comments may be shown as answers.

How to use Multivalue string parameters?

3 Answers 512 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Lok
Top achievements
Rank 1
Lok asked on 10 Mar 2011, 06:30 PM
Hi All,

I'm trying to build a report that accepts parameters during run time and the parameter is a String, i.e the user needs to select the Type of Transaction from a list of available types in the database and then I run a query to fetch all the records from the database which belong to the types of transactions selected by the user. When I enable MultiValue property in the Report Parameter Collection Editor I get the following error: "Object must implement IConvertible"
Please help, I need to fix this issue ASAP.
Thanks in advance!

3 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 15 Mar 2011, 07:50 PM
Hi Lok,

Do you use Stored Procedure with MultiValue Report Parameter? If this is the case then the DataSource Components do not support MultiValue Report Parameter for Stored Procedures because it is based on ADO.NET and does not allow you to pass a collection of values (set, array). The SqlDataSource component supports parametrized SQL queries by associating the parameters you add to the Parameters collection with placeholders in the SelectCommand query. Parameter values can be evaluated with any expression which conforms to the common expression syntax supported by the reporting engine. This grants you a great deal of flexibility on how you can supply your SQL queries with parameters. Unfortunately the above approach is not applicable for stored procedures.

As a workaround our suggestion is to set the SqlDataSource parameter to a comma separated string of the values. I have attached a sample report as an example. In order to run it you will need the AdventureWorks database that came with your installation of Telerik Reporting. Additionally you will need GetByProductNames stored procedure:

USE [AdventureWorks] 
GO 
SET ANSI_NULLS ON 
GO 
SET QUOTED_IDENTIFIER ON 
GO 
     
CREATE PROCEDURE [dbo].[GetByProductNames] 
@Names nvarchar(MAX) 
AS  
BEGIN 
        SELECT p.ProductID, p.Name, p.Color FROM Production.Product AS p WHERE CHARINDEX( ',' + p.Name + ',', ',' + @Names + ',' ) > 0
  
END

Regards,
Peter
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Meckie Bello
Top achievements
Rank 1
answered on 22 Feb 2012, 02:04 AM
Would you have the sample files for VB?
0
Steve
Telerik team
answered on 22 Feb 2012, 08:44 AM
Hello Meckie,

We have added out of the box support for queries for multivalue report parameters (see Using Multivalue Parameters) for our SqlDataSource Component. Stored procedures are still not supported directly as ADO.NET does not support passing a multivalue parameter array to a stored procedure.

To convert the provided project to VB.NET, please use the Telerik Code Converter.

Kind regards,
Steve
the Telerik team
NEW in Q1'12: Telerik Report Designer (Beta) for ad-hoc report creation. Download as part of Telerik Reporting Q1 2012. For questions and feedback, use the new Telerik Report Designer Forum.
Tags
General Discussions
Asked by
Lok
Top achievements
Rank 1
Answers by
Peter
Telerik team
Meckie Bello
Top achievements
Rank 1
Steve
Telerik team
Share this question
or