I have an application that builds the SQL Select statement and creates the report in ReportViewer. The trouble is this, it will not reset the data that is already loading in the report. I have to close out of the ReportViewer screen and come back in to make new selection options. What am I missing?.
ReportViewer.ProcessingMode = ProcessingMode.Local
Dim rView As LocalReport = ReportViewer.LocalReport
rView.ReportPath = "myReport.rdlc"
Dim ds As DataSet = GetDonorData() '<-- This executes my sql query
Dim dsDonor As New ReportDataSource()
dsDonor.Name = "dsDonor_Data"
dsDonor.Value = ds.Tables("dsDonor")
rView.DataSources.Add(dsDonor)
PrivateFunction GetDonorData()
Dim dsDispAsNew DataSet
Dim sqlDonorDataAsString ="SELECT * from Table Where Class =" & selitem
Using connectionAsNew SqlConnection("Data Source=Server;"persist security info=False;Database=Test")
Dim commandAsNew SqlCommand(sqlDonorData, connection)
Dim DonorAdapterAsNew SqlDataAdapter(command)
DonorAdapter.Fill(dsDisp,"dsDonor")
DonorAdapter.Dispose()
command.Dispose()
Return dsDisp
EndFunction
If anyone is interested, I added:
"rView.DataSources.Clear" just before the add statement.
Thanksklschultz013
For anyone interested this is slightly different and in C#
//RV2 is the report
RV2.ProcessingMode = ProcessingMode.Local;
RV2.LocalReport.ReportPath = "Reporting/ReportBookings.rdlc"; //the physical name of the report
DataSet ds = RunStoredProcSelect(spStr, ParsArray, ParCnt);//function to return a dataset
ReportDataSource rptds = new ReportDataSource();
rptds.Name = "DataSet1_bBookingSelect";//Name of the Datasource in the Report [as in the report designer]
rptds.Value = ds.Tables[0];
RV2.LocalReport.DataSources.Clear();
RV2.LocalReport.DataSources.Add(rptds);
RV2.LocalReport.Refresh();
No comments:
Post a Comment