reportDocument1.Load("d:/.../report1.rpt");如果rpt是直接从数据库中建立连接来做的,也就是说直接从表里取数据,那么需要登录:
reportDocument1.Database.Tables
每个table.ApplyLogOnInfocrystalReportViewer1.ReportSource = reportDocument1;
crystalReportViewer1.RefreshReport();

解决方案 »

  1.   


      crystalReportViewer1.ReportSource = reportDocument1;
    crystalReportViewer1.DataBind();
      

  2.   

    都不行,最好能有一个WebForm1.aspx的完整的源代码!
      

  3.   


    简单的显示
    前台:
    <cr:CrystalReportViewer id="rpView" Width="350px" runat="server" DisplayGroupTree="False" DisplayToolbar="False" Height="50px" SeparatePages="False"></cr:CrystalReportViewer>后台:
    private void doBind()
    {
    rpView.ParameterFieldInfo.Clear();
    string strPath="/reports" + ViewState["reportName"].ToString();
    CrystalDecisions.CrystalReports.Engine.ReportDocument myDoc=InitReportDoc( Server.MapPath(strPath),"ConnectionPWD");
    }
    rpView.ReportSource= myDoc;
    rpView.RefreshReport();

    }            public ReportDocument InitReportDoc(string reportPath,string passWrd)
    {
    ReportDocument oRD = new ReportDocument();
    oRD.Load(reportPath);

    this.SetConnectionInfo(oRD,passWrd);

    return oRD;

    }
      

  4.   

    强烈不建议水晶报表在设计时直接和数据库表相连接,
    这样如果你要迁移系统时就会很麻烦的。
    你可以在项目中建一个MyDataSet.xsd数据集,在其中建立你要用到的表的结构,
    在设计报表时用这个xsd文件作数据源。
    然后在代码中实例化这个xsd数据集的实例,
    MyDataSet ds = new MyDataSet();
    读取数据填充这个ds,再把这个ds作为水晶报表的数据源!
    这样浏览水晶报表时就不必考虑登录的问题!
    迁移系统也会方便的!