【发布时间】:2013-11-30 15:46:19
【问题描述】:
我是水晶报表的新手,需要一些帮助: 我已经通过以下两种方式设置了报表数据库登录:
第一个:rpt.SetDatabaseLogon(userId, userPassword);
第二个:DatabaseLogOn(fullserverName, dBName, dBUser, userPassword);
第一种方法运行良好,但由于某些原因我需要将其更改为第二种方法,但是 不幸的是,它不起作用,我不知道原因:
public void DatabaseLogOn(string serverstring, string databasestring, string useridstring, string passwordstring)
{
var crConnectionInfo = new ConnectionInfo();
crConnectionInfo.ServerName = serverstring;
crConnectionInfo.DatabaseName = databasestring ;
crConnectionInfo.UserID = useridstring ;
crConnectionInfo.Password = passwordstring ;
crConnectionInfo.IntegratedSecurity = true;
var crTableLogonInfo = new TableLogOnInfo();
Tables CrTables;
CrTables = rpt.Database.Tables;
foreach (Table crTable in CrTables)
{
crTableLogonInfo = crTable.LogOnInfo;
crTableLogonInfo.ConnectionInfo = crConnectionInfo;
crTable.ApplyLogOnInfo(crTableLogonInfo);
}
Sections CrSections = rpt.ReportDefinition.Sections;
// loop through all the sections to find all the report objects
foreach (Section CrSection in CrSections)
{
ReportObjects CrReportObjects = CrSection.ReportObjects;
//loop through all the report objects in there to find all subreports
foreach (ReportObject CrReportObject in CrReportObjects)
{
if (CrReportObject.Kind == ReportObjectKind.SubreportObject)
{
SubreportObject CrSubreportObject = (SubreportObject)CrReportObject;
//open the subreport object and logon as for the general report
ReportDocument CrSubreportDocument = CrSubreportObject.OpenSubreport(CrSubreportObject.SubreportName);
CrTables = CrSubreportDocument.Database.Tables;
foreach (Table aTable in CrTables)
{
crTableLogonInfo = aTable.LogOnInfo;
crTableLogonInfo.ConnectionInfo = crConnectionInfo;
aTable.ApplyLogOnInfo(crTableLogonInfo);
}
}
}
}
}
谁能帮忙
【问题讨论】:
标签: c# asp.net crystal-reports oracle11g