在C#.net的Crystal Report参数中显示多个数据 [英] Show multiple data in parameters of crystal report in C#.net

查看:113
本文介绍了在C#.net的Crystal Report参数中显示多个数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在VS 2008中制作水晶报表,并且想要添加一个子报表,我编写了以下命令


1)CrystalReport1 cr =新的CrystalReport1();
2)DataSet ds = new DataSet();
3)ds.Tables.Add("table");
4)ds.Tables [0] .Columns.Add("name");
5)ds.Tables [0] .Rows.Add("fksdfs");
6)cr.OpenSubreport("CrystalReport1.rpt").SetDataSource(ds.Tables ["table"]);
7)crystalReportViewer1.ReportSource = cr;

在第6行出现错误:对象引用未设置为对象的实例"

我不知道如何解决!任何人都可以帮忙!急!!

Im making crystal report in VS 2008,And want to add a subreport,I have written following commands


1)CrystalReport1 cr = new CrystalReport1();
2) DataSet ds = new DataSet();
3) ds.Tables.Add("table");
4) ds.Tables[0].Columns.Add("name");
5) ds.Tables[0].Rows.Add("fksdfs");
6)cr.OpenSubreport("CrystalReport1.rpt").SetDataSource(ds.Tables["table"]);
7)crystalReportViewer1.ReportSource = cr;

getting error in 6th line : "Object reference not set to an instance of an object"

I have no clue how to resolve!!Can anyone plz help!!its urgent!!

推荐答案

对象引用未设置为对象的实例
该错误仅表示某些对象值为null,而您试图直接在某处使用它或使用其属性.

使用DEBUGGER可以告诉您确切的对象.收到此错误时,您已经知道该行(此处未提及).即使您不知道,简单的调试也会告诉您.

现在在这里,
该错误很可能是在行中:
Object reference not set to an instance of an object
This error simply means that some object value is null and yet you are trying to use it somewhere directly or using it''s properties.

Using DEBUGGER can tell you the exact object. When you got this error, you already know the line (which you have not mentioned here). Even if you are not aware, a simple debugging would tell you that.

Now here,
most probably the error is in line:
cr.OpenSubreport("CrystalReport1.rpt").SetDataSource(ds.Tables["table"]);



您正在尝试使用方法"OpenSubreport"打开子报表,但是您没有在定义水晶报表对象"cr"的位置处定义子报表.

了解如何通过代码动态添加子报表.



You are trying to open a subreport using a method ''OpenSubreport'' but you have no where defined that the crystal report object ''cr'' has one.

Read on how to add subreports dynamically through code.


这篇关于在C#.net的Crystal Report参数中显示多个数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆