我有一个报告,当点击链接子报告时,我得到数据库登录表单。我已经提供了所有必要的连接字符串但仍然要求登录info.sub报告在我的本地系统中打开但是当安装在客户端系统中时我得到这个问题。我缺少什么或我该怎么做?
答案 0 :(得分:1)
我发现在水晶报表的代码中设置数据库连接时,需要在报表数据库定义中的每个表上设置连接。你可以这样做:
private static void SetConnectionInfo(ReportClass report, string ReportServer, string ReportDatabase)
{
TableLogOnInfo tInfo = new TableLogOnInfo();
ConnectionInfo connectionInfo = tInfo.ConnectionInfo;
connectionInfo.IntegratedSecurity = true;
connectionInfo.ServerName = ReportServer;
connectionInfo.DatabaseName = ReportDatabase;
foreach (Table t in report.Database.Tables)
{
t.ApplyLogOnInfo(tInfo);
}
foreach (ReportClass subReport in report.Subreports)
{
SetConnectionInfo(subReport, ReportServer, ReportDatabase);
}
}