rdlc报表问题
private void label1_Click(object sender, EventArgs e){
//MessageBox.Show("label1");
this.label1.Cursor = Cursors.Hand;
Form4 fr4 = new Form4();
if (fr4.ShowDialog() == DialogResult.Cancel)
{
string xm = fr4.InputValue;
DBCon db = new DBCon();
OleDbConnection conn = db.CreateCon();
string strSql = "select * from Revenue where InComeName='" + xm + "'";
OleDbCommand cmd = new OleDbCommand(strSql, conn);
OleDbDataAdapter oda = new OleDbDataAdapter(cmd);
DataSet accountsDataSet_Revenue = new DataSet();
try
{
conn.Open();
oda.Fill(accountsDataSet_Revenue);
}
finally
{
conn.Close();
// cmd.Dispose();
//conn.Dispose();
}
//为报表浏览器指定报表文件
string path = @"D:\\rdlc_report\\rdlcrpt3\\rpt\\rpt\\Rev_Report.rdlc";
reportViewer1.LocalReport.ReportPath = path;
//指定数据集,数据集名称后为表,不是DataSet类型的数据集
this.reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("accountsDataSet", accountsDataSet_Revenue.Tables[0]));
//显示报表
this.reportViewer1.RefreshReport();
}
}
private void label3_Click(object sender, EventArgs e)
{
Form4 fr4 = new Form4();
if (fr4.ShowDialog() == DialogResult.Cancel)
{
string xm = fr4.InputValue;
DBCon db = new DBCon();
OleDbConnection conn = db.CreateCon();
string strSql = "select * from Expendtl where ExOutNo='" + xm + "'";
OleDbCommand cmd = new OleDbCommand(strSql, conn);
OleDbDataAdapter oda = new OleDbDataAdapter(cmd);
DataSet Expen_ds = new DataSet();
try
{
conn.Open();
oda.Fill(Expen_ds);
}
finally
{
conn.Close();
//cmd.Dispose();
//conn.Dispose();
}
//为报表浏览器指定报表文件
string path = @"D:\\rdlc_report\\rdlcrpt3\\rpt\\rpt\\Expen_Report.rdlc";
reportViewer1.LocalReport.ReportPath = path;
//指定数据集,数据集名称后为表,不是DataSet类型的数据集
this.reportViewer1.LocalReport.DataSources.Clear();
this.reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("Expen_ds", Expen_ds.Tables[0]));
//显示报表
this.reportViewer1.RefreshReport();
}
问:如果我先点label1报表显示正常,接着点label3报数据源错误,数据源为什么还是label1的数据源呢?
如果我先点label3报表显示也正常,接着点label1报数据源错误,数据源为什么还是label3的数据源呢?
分有点少,忘那位好心的大哥帮帮我嘛!