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

Changing Datasource for Report at Runtime

0 Answers 441 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Maas Prog
Top achievements
Rank 1
Maas Prog asked on 11 Jul 2012, 06:29 PM
I could not find an answer to this so opened a ticket and got a quick response, which I though I would post here for others...perhaps I am kind of dense, but the breaking changes in the new release confused the heck out of me...

Hi - I just updated to 6.1.12.611 reports release and all my reports broke. I cannot figure out how to change the following code in my report viewer in my web application to work with new release. There are no VB examples that I can find.
I want to simply change the datasource property of the report at runtime. I have a custom class in my web application that provides a datatable just by passing the sql. I could then set the newly created table as the datasource at runtime. 
This used to work:
Dim report1 As New myReports.ProjectList
Dim tbl As DataTable =  db.ExecuteDataTable("SELECT * FROM mydata WHERE ProgramID = " & nProgramID)
report1.DataSource = tbl
ReportViewer1.Report = report1

I am lost -- 
I got this far but cannot find a datasource property to set anywhere....:
Dim report1 As New Telerik.Reporting.InstanceReportSource
report1.ReportDocument = New myReports.ProjectList 
ReportViewer1.ReportSource = report1

Please help.
Thanks
Ford 

----------------------------------- Answer      -----
Hello Ford,

The Report Sources are not report documents, they are the connection between multiple report documents or report documents and viewers, so I guess naming your InstanceReportSource with report1 is where the confusion comes from.

Dim report1 As New myReports.ProjectList
Dim tbl As DataTable =  db.ExecuteDataTable("SELECT * FROM mydata WHERE ProgramID = " & nProgramID)
report1.DataSource = tbl
ReportViewer1.Report = report1

should be:

Dim report1 As New myReports.ProjectList
Dim tbl As DataTable =  db.ExecuteDataTable("SELECT * FROM mydata WHERE ProgramID = " & nProgramID)
report1.DataSource = tbl
Dim instanceReportSource As New Telerik.Reporting.InstanceReportSource()
instanceReportSource.ReportDocument = report1
ReportViewer1.ReportSource = instanceReportSource


Kind regards,
Steve 
the Telerik team 

No answers yet. Maybe you can help?

Tags
General Discussions
Asked by
Maas Prog
Top achievements
Rank 1
Share this question
or