10 Answers, 1 is accepted
Please take a look at the following KB article that explains how to work with stored procedures and let us know if further help is needed.
Regards,
Steve
the Telerik team
Check out Telerik Trainer , the state of the art learning tool for Telerik products.
I want to pass a GUID to a query as a parameter so going through the steps in the above article. However, in the report parameters collection in the GUI there isn't a type for uniqueidentifier, so I get a type clash when I run the report...
Matt
You need to set the type of the report parameter as string and filter on the GUID column without problems e.g.:
this.Filters.Add(new Telerik.Reporting.Data.Filter("=Fields.rowguid", Telerik.Reporting.Data.FilterOperator.Equal, "= Parameters.paramGuid"));
and here is the parameter :
this.ReportParameters["paramGuid"].Value = "cfbda25c-df71-47a7-b81b-64ee161aa37c";
Sincerely yours,
Steve
the Telerik team
Check out Telerik Trainer , the state of the art learning tool for Telerik products.
thanks for the reply.
I'm only just starting using the reporting product so correct me if I'm wrong.
Wouldn't this solution mean I was filtering in the report and would have retrieved all the records from the DB? Really don't want to do this as the table is very large and seems wasteful?
Regards
Matt
I have to send parameter (Guid) into store procedure. I do't want select all of records from databases and after to filter it. It could be 100 000 records.
Regards.
Leszek
There is no problem to do that as well. Make sure the report parameter's type is string and the Guid class contains an overload which accepts string as argument, so make sure you handle it accordingly.
Sincerely yours,
Steve
the Telerik team
Check out Telerik Trainer , the state of the art learning tool for Telerik products.
CREATE PROCEDURE procRptPrf
@PId varchar(50)
AS
BEGIN
DECLARE @ParticipantId as uniqueidentifier
SELECT @ParticipantId = cast(@Pid as uniqueidentifier)
SELECT [ProgramName]
,[SiteName]
...
,[StageDrug]
FROM [Sbirt].[dbo].[vwRptPfr]
WHERE @ParticipantId = ParticipantId
END
Hi,
It is very easy when you add DataSource programatycly
//constructor
public void MyReport()
{
InitializeComponents();
SqlConnection sqlConnection1 = new SqlConnection();
SqlCommand sqlSelectCommand1 = new SqlCommand();
SqlDataAdapter sqlDataAdapter1 = new SqlDataAdapter();
// define a connection string
sqlConnection1.ConnectionString = Properties.
Settings.Default.RRLevel1DBCS;
// define the command object properties
sqlSelectCommand1.CommandType =
CommandType.StoredProcedure;
sqlSelectCommand1.CommandText =
"SelectNewExceptionsForAssetRep";
sqlSelectCommand1.Parameters.Add(
new SqlParameter("@AssetGuid", gu));
sqlSelectCommand1.Connection = sqlConnection1;
sqlDataAdapter1.SelectCommand = sqlSelectCommand1;
this.DataSource = sqlDataAdapter1;
}
How can I do that, but for a Report that is "called" in a subreport item ?
I'm trying to pass parameters for a report within subreport, but I can't get work. The data for report (the report called within subreport item as report source) is too from a stored procedure.
Thanks in advance.
PD. I'm using the trial version of Reporting (v3.0), VisualStudio 2008 and C#
Thanks for posting the script. This saved me a lot of time!