c#中的.rdlc报告不显示任何输出数据?

时间:2013-04-09 02:58:19

标签: c# dataset rdlc

我的朋友们正在使用visual studio 2008,我在c#中开发小项目,现在我想在其中添加报告,(。rdlc报告)。这是我的代码

 try
        {
            reportViewer1.Reset();
            con.Open();
            command.Connection = con;
            command.CommandType = CommandType.StoredProcedure;
            command.CommandText = "select_book_specific";

            param = new SqlParameter("@isbn", "isbn1");
            param.Direction = ParameterDirection.Input;
            param.DbType = DbType.String;
            command.Parameters.Add(param);

            adapter = new SqlDataAdapter(command);
            adapter.Fill(ds);


         //  for (int i = 0; i <= ds.Tables[0].Columns.Count - 1; i++)
           // {

             //   MessageBox.Show(ds.Tables[0].Rows[0][i].ToString());

            //} For testing purpose

            this.reportViewer1.LocalReport.ReportPath = @"C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\WindowsFormsApplication1\WindowsFormsApplication1\Report1.rdlc";


this.reportViewer1.LocalReport.DataSources.Add(newReportDataSource("Books",ds.Tables[0].TableName.ToString()));
this.reportViewer1.RefreshReport();


}
catch(exception ex){messageBox.show(ex.message);}

1 个答案:

答案 0 :(得分:0)

尝试

try
{
    reportViewer1.Reset();
    con.Open();
    command.Connection = con;
    command.CommandType = CommandType.StoredProcedure;
    command.CommandText = "select_book_specific";

    param = new SqlParameter("@isbn", "isbn1");
    param.Direction = ParameterDirection.Input;
    param.DbType = DbType.String;
    command.Parameters.Add(param);

    adapter = new SqlDataAdapter(command);
    adapter.Fill(ds);
    this.reportViewer1.LocalReport.ReportPath = @"C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\WindowsFormsApplication1\WindowsFormsApplication1\Report1.rdlc";
    this.reportViewer1.LocalReport.DataSources.Clear();
    this.reportViewer1.LocalReport.DataSources.Add( new ReportDataSource(ds.DataSetName + "_" + ds.TableName, ds.Tables[0]));
    this.reportViewer1.LocalReport.Refresh();
}catch(Exception ex)
{
    messageBox.show(ex.message);
}