Thank you for the help.
But i can't get it to work. I think i was able to call the different
datasets from the rdlc file but i won't know for sure until i actually
see it working. This is the code i am using
private void ButtonTableA_Clicked(object sender, EventArgs e)
{
SetSelectedTable("Report1.rdlc", sender, e);
}
private void ButtonTableB_Clicked(object sender, EventArgs e)
{
SetSelectedTable("Report2.rdlc", sender, e);
}
private void SetSelectedTable(string TableName, object sender,
EventArgs e)
{
ReportParameter p = new ReportParameter("SelectedTable",
TableName);
this.reportViewer1.LocalReport.SetParameters(new
ReportParameter[] { p });
this.reportViewer1.RefreshReport();
}
I just changed TableA and TableB to Report1.rdlc and Report2.rdlc. I
am thinking that this is the right way to do it but i am not sure. I
understand the big picture of this code but not in detail. The problem
i get when i try to run the code is at this line
this.reportViewer1.LocalReport.SetParameters(new ReportParameter[]
{ p });
the error i get is
LocalProcessingException was unhandled.
I get this error at runtime. I have googled and i have seen other
examples like this where that like was not handled as exception so i
am thinking that it should not be. But then i think i have done
something wrong somewhere else in the code. Any suggestion of what
that could be are greatly appriciated.
Thanks in advance.
B
On Nov 23, 6:36 am, Wendi Turner <[email protected]> wrote:
> Call the different report "tables" or "datasets" from within the rdlc, swap
> the displayed report tables with parameters passed into the reportviewer.
>
> private void ButtonTableA_Clicked(object sender, EventArgs e)
> {
> SetSelectedTable("TableA", sender, e);
> }
> private void ButtonTableB_Clicked(object sender, EventArgs e)
> {
> SetSelectedTable("TableB", sender, e);
> }
>
> private void SetSelectedTable(string TableName, object sender,
> EventArgs e)
> {
> ReportParameter p = new
> ReportParameter("SelectedTable", TableName);
> this.reportViewer1.LocalReport.SetParameters(new
> ReportParameter[] { p });
> this.reportViewer1.RefreshReport();
> }
>
>
>
> On Thu, Nov 19, 2009 at 7:12 PM, Mr. B <[email protected]> wrote:
> > Hello
>
> > I want to write a simple application. Simple as in it is easy to
> > describe but i can't figure it out.
>
> > This application that i want to create has a report viewer that shows
> > the contents of the tables in the database as reports. I have a
> > database with two tables in it: TableA and TableB. The GUI of the
> > application has two button plus the reportviewer. One of the buttons
> > is called A and the other one B. When i click the button A i want the
> > report viewer to display the contents of TableA. When i click the
> > button B i want ... you guessed it... the reportviewer to display the
> > contents of TableB as a report.
>
> > The problem i have is that i cannot seem to assign a new data source
> > to the reportviewer. When you add a reportviewer to your app in visual
> > studio 2008 you have to give it a datasource. I do this but then i
> > can't change this data source later in the application. I have created
> > separate rdlc files for the two reports and i am trying to give the
> > reportviewer a new data source but it seems to be "stuck" with the
> > data source that it got when i created it. I have googled this a lot
> > and all i can see is that i need a DataSet that contains the info from
> > the tables and i have to use this dataset as a datasource but it's not
> > working. Does anybody have some sample code that does this? Or knows
> > where i can find it? I have looked but could not find it. A thourough
> > explanation would also be nice. Thanks in advance.
>
> > Cheers
>
> --
> Wendi
> cell: 949-606-4877
>
> "Energizer Bunny arrested, charged with battery."