解决水晶报表出现登陆框的问题
2006-01-05 08:51
465 查看
你最好还是用sql连接,因为oledb和sql的连接信息不是一样的.
如果你用的是水晶报表的推模式,一般不用设置登陆信息,但是要这样写:obj.SetDataSource(this.ds.Tables["tablename"]);如果你写成了obj.SetDataSource(this.ds)就会有登陆框的。
如果你用的是水晶报表的拉模式,你就一定要写上登陆信息:
crReportDocument = new OracleReport();
//Set the crConnectionInfo with the current values stored in the report
crConnectionInfo = crReportDocument.Database.Tables[0].LogOnInfo.ConnectionInfo;
/* Populate the ConnectionInfo Objects Properties with the appropriate values for
the ServerName, User ID, Password and DatabaseName. However, since Oracle
works on Schemas, Crystal Reports does not recognize or store a DatabaseName.
Therefore, the DatabaseName property must be set to a BLANK string. */
crConnectionInfo.DatabaseName = "";
crConnectionInfo.ServerName = "Your Server Name";
crConnectionInfo.UserID = "Your User ID";
crConnectionInfo.Password = "Your Password";
//Set the CrDatabase Object to the Report's Database
crDatabase = crReportDocument.Database;
//Set the CrTables object to the Tables collection of the Report's dDtabase
crTables = crDatabase.Tables;
//Loop through each Table object in the Tables collection and apply the logon info
//specified ealier. Note this sample only has one table so the loop will only execute once
foreach (Table crTable in crTables)
{
crTableLogOnInfo = crTable.LogOnInfo;
crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
crTable.ApplyLogOnInfo (crTableLogOnInfo);
// if you wish to change the schema name as well, you will need to set Location property as follows:
// crTable.Location = "<new schema name>." + crTable.Name;
}
//Set the ReportSource of the CrystalReportViewer to the strongly typed Report included in the project
crystalReportViewer1.ReportSource = crReportDocument;
还有一点要注意:
如果你用到了子报表,一定要处理:
//Go through each sections in the main report and identify the subreport by name
crSections = crReportDocument.ReportDefinition.Sections;
foreach(Section crSection in crSections)
{
crReportObjects = crSection.ReportObjects;
//loop through all the report objects to find all the subreports
foreach(ReportObject crReportObject in crReportObjects)
{
if (crReportObject.Kind == ReportObjectKind.SubreportObject)
{
//you will need to typecast the reportobject to a subreport
//object once you find it
crSubreportObject = (SubreportObject)crReportObject;
//open the subreport object
crSubReportDoc = crSubreportObject.OpenSubreport(crSubreportObject.SubreportName);
//Once the correct subreport has been located pass it the
//appropriate dataset
if(crSubReportDoc.Name == "FirstSub")
{
//crSubReportDoc.Database.Tables[0].SetDataSource(ds);
crSubReportDoc.SetDataSource(ds);
}
}
}
}
crystalReportViewer1.ReportSource = crReportDocument;
同样crSubReportDoc.SetDataSource(ds);改为:crSubReportDoc.SetDataSource(ds.Tables["tablename"]);
http://dev.csdn.net/develop/article/76/76324.shtm
如果你用的是水晶报表的推模式,一般不用设置登陆信息,但是要这样写:obj.SetDataSource(this.ds.Tables["tablename"]);如果你写成了obj.SetDataSource(this.ds)就会有登陆框的。
如果你用的是水晶报表的拉模式,你就一定要写上登陆信息:
crReportDocument = new OracleReport();
//Set the crConnectionInfo with the current values stored in the report
crConnectionInfo = crReportDocument.Database.Tables[0].LogOnInfo.ConnectionInfo;
/* Populate the ConnectionInfo Objects Properties with the appropriate values for
the ServerName, User ID, Password and DatabaseName. However, since Oracle
works on Schemas, Crystal Reports does not recognize or store a DatabaseName.
Therefore, the DatabaseName property must be set to a BLANK string. */
crConnectionInfo.DatabaseName = "";
crConnectionInfo.ServerName = "Your Server Name";
crConnectionInfo.UserID = "Your User ID";
crConnectionInfo.Password = "Your Password";
//Set the CrDatabase Object to the Report's Database
crDatabase = crReportDocument.Database;
//Set the CrTables object to the Tables collection of the Report's dDtabase
crTables = crDatabase.Tables;
//Loop through each Table object in the Tables collection and apply the logon info
//specified ealier. Note this sample only has one table so the loop will only execute once
foreach (Table crTable in crTables)
{
crTableLogOnInfo = crTable.LogOnInfo;
crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
crTable.ApplyLogOnInfo (crTableLogOnInfo);
// if you wish to change the schema name as well, you will need to set Location property as follows:
// crTable.Location = "<new schema name>." + crTable.Name;
}
//Set the ReportSource of the CrystalReportViewer to the strongly typed Report included in the project
crystalReportViewer1.ReportSource = crReportDocument;
还有一点要注意:
如果你用到了子报表,一定要处理:
//Go through each sections in the main report and identify the subreport by name
crSections = crReportDocument.ReportDefinition.Sections;
foreach(Section crSection in crSections)
{
crReportObjects = crSection.ReportObjects;
//loop through all the report objects to find all the subreports
foreach(ReportObject crReportObject in crReportObjects)
{
if (crReportObject.Kind == ReportObjectKind.SubreportObject)
{
//you will need to typecast the reportobject to a subreport
//object once you find it
crSubreportObject = (SubreportObject)crReportObject;
//open the subreport object
crSubReportDoc = crSubreportObject.OpenSubreport(crSubreportObject.SubreportName);
//Once the correct subreport has been located pass it the
//appropriate dataset
if(crSubReportDoc.Name == "FirstSub")
{
//crSubReportDoc.Database.Tables[0].SetDataSource(ds);
crSubReportDoc.SetDataSource(ds);
}
}
}
}
crystalReportViewer1.ReportSource = crReportDocument;
同样crSubReportDoc.SetDataSource(ds);改为:crSubReportDoc.SetDataSource(ds.Tables["tablename"]);
http://dev.csdn.net/develop/article/76/76324.shtm
相关文章推荐
- 水晶报表运行一段时间后出现的两个问题及解决办法
- 水晶报表 push模式连接 解决登陆问题 和参数传输问题
- 解决把水晶报表下载到客户端过程中,出现下载整个页面(.aspx)或者直接载web页中打开word文件的问题!
- 故障解决:VS2005的水晶报表在WEB应用程序中多次使用后,就会出现加载报表失败.重启WEB服务器又正常了.过一段时间又出同样问题
- 水晶报表 创建odbc数据源出现 在指定的 DSN 中,驱动程序和应用程序之间的体系结构不匹配 问题解决
- .Net环境水晶报表在98下发布,出现"不能加载报表..."问题的解决
- 故障解决:VS2005的水晶报表在WEB应用程序中多次使用后,就会出现加载报表失败.重启WEB服务器又正常了.过一段时间又出同样问题
- 【原】[Crystal Reports]水晶报表分组后出现空白页问题的解决
- 关于水晶报表出现登录窗口问题的解决方法
- 水晶报表在网站迁移过程中出现的问题及解决方法
- 【解决】ssh登陆远程服务器后,gcc编译出现乱码问题
- 出现"此版本的sql server不支持用户实例登陆标志" 问题的解决方法
- 【游戏开发备注之三】GameCenter登陆出现“无法识别此游戏”问题的两种解决方法
- 解决水晶报表部署时出错的问题
- .Net环境下水晶报表不能动态更新的问题原由及解决
- 解决水晶报表登录问题
- [转] 彻底解决水晶报表中登陆的错误 [http://blog.csdn.net/wzhibin/archive/2007/06/01/1634370.aspx]
- 解决水晶报表客户端打印问题的方法
- 解决水晶报表设计的宽度问题——当显示列比较多的时候
- mantis统计报表和图形报表出现乱码问题的解决方法(摘录)