I've created some reports and deployed on Report Server 2005, and I created a winform application using ReportViewer control to display the reports. Can I assign data source to report during runtime like logon database in Crystal Reports, because I've several database with the same structure, I want to use one report file for all database by switching the data source in my winform application. Does anyone know how can I do this
Thank you very much!!!

Dynamic data source at runtime?
Learning VB
You can change the datasource collection by using the collection:
.LocalReport.DataSources.Add(DataSource)
.LocalReport.DataSources.Item(0) = datasource
Hope that helps.
joerg123
I'm trying to do something similar. I have a VB project I just converted from VB.NET to VB 2005. It has a bunch of reports created using DataDynamics ActiveReports 1.0 for .NET which isn't compatible with VB2005. So I'm investigating whether I can use the built in reporting tools in Visual Studio or if we have to buy the latest ActiveReports controls.
I have a bunch of SQL Server stored procedures with the queries in them and code to run the SPs and populate dataset objects in code. I'd like to be able to just link up these dataset objects to the reports at runtime and then show the report in a generic form containing the ReportViewer. So far, I can't find any information in the help files regarding how to dynamically set the datasource for the report and also how to dynamically assign a report to the reportviewer at run time. This should be as simple as setting a datasource property on the report at runtime and setting a report property on the reportviewer, but I can't find such properties.
Cándido
Hi,
I don't understand. According to the MSDN documentation ReportViewer.LocalReport.DataSources collection is read-only
Michael_Shao
edwinzzz
Steve Graber
Sorry I still don't understand. Could you give an example of how you can use this to change the data source dynamically
Thanks
Avi_harush
Thanks for the reply Beltone. I found another way to do it in the mean time in the MSDN documentation for Crystal Reports for .NET datasets (In the Contents Go to > Visual Studio > Tools and Features > Crystal Reports > Tutorials and Sample Code > Data Conectivity Tutorials > Connecting to ADO.NET DataSets > Writing a Helper Class to Populate the DataSet):
Imports
System.DataImports
System.Data.OleDbPublic
Class DataSetConfiguration Public Shared ReadOnly Property PropDataSet() As DataSet Get Dim myDataSet As PropDataSet = New PropDataSet() Dim myOleDbConnection As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + List.dbPath) Dim myOleDbDataAdapter As OleDbDataAdapter = New OleDbDataAdapter("SELECT Prop.* FROM Prop", myOleDbConnection)myOleDbDataAdapter.Fill(myDataSet,
"Prop") Return myDataSet End Get End PropertyEnd
ClassVaiTraFra
Hi,
You can also have a privte datasource in the report.
Private datasources can be dynamic like:
="Initial Catalog=......." + Parameters!.....