【问题标题】:crystal report failed to get data水晶报表获取数据失败
【发布时间】: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


    【解决方案1】:

    您查看过这个post 吗?它几乎与您的相同,并且该帖子的答案表明结构略有变化。

    【讨论】:

    • 感谢 campagnolo_1,但如果您观察到我使用的方法与您在帖子中提到的方法相同,但报告在运行时显示为空,尽管它在报告预览中返回数据并带有 1st方式。
    • rpt.SetDatabaseLogon(userId, userPassword);但我需要在运行时更改 dbconnection 第二种方法是处理我们在项目中拥有的一些报告......它们之间唯一的区别是不工作报告中的子报告,但尽管在删除子报告后它不起作用跨度>
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多