Can-Ann

I have two buttons and reportviewer on a form.

button (A) runs reportA, button (B) runs reportB.

I use the following routine to print the reports:

The first report (A) runs fine but when I select report (B) it reprints report (A) - is there a way to clear, or reset the report viewer

Code Snippet

public static void MyReport(string strSql, ReportViewer rvObject, string strReportName, string strTable)

{

//Create array of tables in the db

strDSName[0] = "DB_EmployeeDataSet_Employee";

strDSName[1] = "DB_EmployeeDataSet_Shift";

strDSName[2] = "DB_EmployeeDataSet_Company";

strDSName[3] = "DB_EmployeeDataSet_Department";

strDSName[4] = "DB_EmployeeDataSet_ClockTransactions";

strDSName[5] = "DB_EmployeeDataSet_Dependants";

strDSName[6] = "DB_EmployeeDataSet_HealthTransactions";

//Create the dataset

OleDbConnection MyConnection = new OleDbConnection(MyConnectionStr);

DataSet MyDataSet = WindowsApplication1.Class1.GetDataset(strSql, MyConnection, strTable);

//Bind to the report

rvObject.LocalReport.DataSources.Clear();

rvObject.LocalReport.ReportPath = strPath + strReportName;

//Associate new dataset with the reportviewer datasource

for (int i = 0; i <= 6; i++)

{

rvObject.LocalReport.DataSources.Add(new ReportDataSource(strDSName[i], MyDataSet.Tables[0]));

}

//Do not use localreport to refresh

rvObject.RefreshReport();

MyDataSet.Dispose();

}



Re: Windows Forms Data Controls and Databinding How to run multiple reports on a reportviwer

Zhi-Xin Ye - MSFT

You can try the ReportViewer.Reset Method






Re: Windows Forms Data Controls and Databinding How to run multiple reports on a reportviwer

Can-Ann

Thank you works perfectly.