读书人

用2010cry作的报表提示未实例化

发布时间: 2013-01-11 11:57:35 作者: rapoo

用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中可以正常。


[解决办法]
将对象引用设置到对象的实例

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

调试下即知

读书人网 >.NET

热点推荐