using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using System.Web.UI.HtmlControls;public partial class Testreport : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
ConfigrationReports();
}
private ReportDocument NorthwindCustomersReport; private void ConfigrationReports()
{
ConnectionInfo connectionInfo = new ConnectionInfo();
connectionInfo.DatabaseName = "Northwind";
connectionInfo.UserID = "sa";
connectionInfo.Password = "sasa";
SetDBLogonForReport(connectionInfo ,NorthwindCustomersReport ); NorthwindCustomersReport = new ReportDocument();
string reportPath = Server.MapPath("NorthwindCustomers.rpt");
NorthwindCustomersReport.Load(reportPath);
CrystalReportViewer1.ReportSource = NorthwindCustomersReport;
}
private void SetDBLogonForReport(ConnectionInfo connectionInfo,ReportDocument reportDocument)
{
//using (CrystalDecisions.CrystalReports.Engine )
Tables tables = reportDocument.Database.Tables; foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables )
{
TableLogOnInfo tableLogonInfo = Table.LogOnInfo;
TableLogOnInfo.ConnecitonInfo = ConnectionInfo;
table.ApplyLogOnInfo(tableLogOnInfo);
}
}
}如上必须包含指向 Table 类的完整命名空间路径,使其与 System.Web.UI.WebControls 命名空间的 Table 类区分开来?,怎么做,我是新手,请高手给以指点?我不会区分,具体在哪声明以区分开啊,
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using System.Web.UI.HtmlControls;public partial class Testreport : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
ConfigrationReports();
}
private ReportDocument NorthwindCustomersReport; private void ConfigrationReports()
{
ConnectionInfo connectionInfo = new ConnectionInfo();
connectionInfo.DatabaseName = "Northwind";
connectionInfo.UserID = "sa";
connectionInfo.Password = "sasa";
SetDBLogonForReport(connectionInfo ,NorthwindCustomersReport ); NorthwindCustomersReport = new ReportDocument();
string reportPath = Server.MapPath("NorthwindCustomers.rpt");
NorthwindCustomersReport.Load(reportPath);
CrystalReportViewer1.ReportSource = NorthwindCustomersReport;
}
private void SetDBLogonForReport(ConnectionInfo connectionInfo,ReportDocument reportDocument)
{
//using (CrystalDecisions.CrystalReports.Engine )
Tables tables = reportDocument.Database.Tables; foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables )
{
TableLogOnInfo tableLogonInfo = Table.LogOnInfo;
TableLogOnInfo.ConnecitonInfo = ConnectionInfo;
table.ApplyLogOnInfo(tableLogOnInfo);
}
}
}如上必须包含指向 Table 类的完整命名空间路径,使其与 System.Web.UI.WebControls 命名空间的 Table 类区分开来?,怎么做,我是新手,请高手给以指点?我不会区分,具体在哪声明以区分开啊,
解决方案 »
- 大数据量的查询程序应该怎么设计
- .net 将文件存储到 内网一个文件服务器,查看时可以进行下载
- 电子商务网站,库存的减少
- 急求解码
- 一个看似简单datagrid的嵌套问题,吉利数字66分求助!
- 问的第一个问题!很简单!
- 怎么把控件的ID但参数传过去?
- 在.net中静态生成文章,而对有些篇幅大的文章要进行分页处理,不知道各位是怎么实现的,思路是什么?
- 在公司内部可以输入sharplee82.vicp.net访问了,可是外网访问不到,是怎么回事?
- 硬盘上所有文件夹全变成只读的(文件没问题),并且改都改不了!!!!!
- GridView分页的问题,高分求教!
- 初学ASP.NET,请问如何通过单击某个按钮打开另外一个页面?
这是具体 的错误信息,请高手帮忙啊,
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using System.Web.UI.HtmlControls; public partial class Testreport : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
ConfigrationReports(); }
private ReportDocument NorthwindCustomersReport; private void ConfigrationReports()
{
//定义登录数据库的具体内容
ConnectionInfo connectionInfo = new ConnectionInfo();
connectionInfo.DatabaseName = "Northwind";
connectionInfo.UserID = "sa";
connectionInfo.Password = "sasa";
//执行登录
SetDBLogonForReport(connectionInfo, NorthwindCustomersReport);
//绑定报表到VIEWER中
NorthwindCustomersReport = new ReportDocument();
string reportPath = Server.MapPath("NorthwindCustomers.rpt");
NorthwindCustomersReport.Load(reportPath);
CrystalReportViewer1.ReportSource = NorthwindCustomersReport; }
//列出登录数据库的方法
private void SetDBLogonForReport (ConnectionInfo connectionInfo, ReportDocument reportDocument)
{
Tables tables = reportDocument.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)
{
TableLogOnInfo tableLogonInfo = table.LogOnInfo;
tableLogonInfo.ConnectionInfo = connectionInfo;
table.ApplyLogOnInfo(tableLogonInfo);
}
}
}
更改了,大小写的问题,但是还有错误:
未将对象引用设置到对象的实例。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。源错误:
行 46:
行 47:
行 48: Tables tables = reportDocument.Database.Tables;
行 49: foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)
行 50: {
源文件: c:\Inetpub\wwwroot\costsites\Testreport.aspx.cs 行: 48
请大家看看是什么问题?
在SetDBLogonForReport方法中,从 ReportDocument 参数的 Database 属性的 Tables 属性,检索 Tables 实例。
注意 Tables 是包含 Table 类实例的索引类。我该怎么做才不出错误呢
SetDBLogonForReport(connectionInfo, NorthwindCustomersReport);
放到绑定的下面执行就可以了,呵。多多交流