本文介绍了创建Crystal报表时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试创建水晶报告usinsg数据集,但出现错误
i am trying to create a crystal report usinsg data set but getting the errors
Error 1 '_Default.CrystalReportViewer1' is a 'field' but is used like a 'type
我做的编码是..
coding i have done is..
protected void Page_Load(object sender, EventArgs e)
{
CrystalReportViewer1 report = new CrystalReportViewer1();//here i am getting error
CrystalReportViewer1.Visible = true;
DataSet ds = new DataSet("DataSet1");
DataTable table = new DataTable("DataSet1");
table.Columns.Add("username", typeof(System.String));
table.Columns.Add("bookno", typeof(System.String));
DataRow row = table.NewRow();
row["username"] = "Farooq";
row["bookno"] = "hyden";
report.SetDataSource(ds);
CrystalReportViewer1.ReportSource = report;
}
推荐答案
protected void Page_Load(object sender, EventArgs e)
{
ReportDocument crypt = new ReportDocument();
CrystalReportViewer1.Visible = true;
DataSet ds = new DataSet("DataSet1");
DataTable table = new DataTable("DataSet1");
table.Columns.Add("username", typeof(System.String));
table.Columns.Add("bookno", typeof(System.String));
DataRow row = table.NewRow();
row["username"] = "Farooq";
row["bookno"] = "hyden";
ReportDocument crypt = new ReportDocument();
string path="D:\\Projects\\CrystalDemo\\CrystalDemo\\CrystalReport1.rpt";
crypt.Load(path);
crypt.SetDataSource(ds);
crystalReportViewer1.ReportSource = crypt;
crystalReportViewer1.Refresh();
}
有关更多详细信息,请检查此 [ ^ ]
希望对您有所帮助:)
for more details check THIS[^]
hope it helps :)
这篇关于创建Crystal报表时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!