日期:2014-05-20  浏览次数:20797 次

用2010cry做的报表,提示未实例化
 我刚学水晶报表,请大家指教。
  用页面拖了二个控件,一个是CrystalReportViewer,CrystalReportSource
 然后写了代码如下:
 protected void ForCrystalReport()
        {
            CrystalReportSource1.ReportDocument.Load(Server.MapPath("zxh.rpt"));
              CrystalReportSource1.ReportDocument.SetDatabaseLogon("sa", "000000", "WIN7U-20120704W", "HXDataBase");
            CrystalReportSource1.DataBind();

            CrystalReportViewer1.ReportSource = CrystalReportSource1;
            CrystalReportViewer1.DataBind();
        }

        protected void CrystalReportViewer1_Init(object sender, EventArgs e)
        {
            ForCrystalReport();
        }

运行时提示“将对象引用设置到对象的实例。 ”,这段代码在VS2008中可以正常。


------解决方案--------------------
将对象引用设置到对象的实例 

就是那个对象没有实例化就调用了 

调试下即知