C# crystal report无法获取数据

C# crystal report无法获取数据,c#,asp.net,crystal-reports,oracle11g,C#,Asp.net,Crystal Reports,Oracle11g,我是crystal report的新手我需要一些帮助: 我已通过以下两种方式设置报表数据库登录: 第一个:rpt.SetDatabaseLogon(userId,userPassword) 第二:数据库登录(fullserverName、dBName、dBUser、userPassword) 第一种方法很有效,但出于某些原因,我需要将其更改为第二种方法,但是 不幸的是,它不起作用,我不知道原因: public void DatabaseLogOn(string serverstring, str

我是crystal report的新手我需要一些帮助: 我已通过以下两种方式设置报表数据库登录:

第一个:rpt.SetDatabaseLogon(userId,userPassword)

第二:数据库登录(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);

                        }
                    }
                }
            }


        }

有人能帮忙吗你查过这个了吗?它和你的几乎一样,而对这篇文章的回答表明,结构有轻微的变化

感谢campagnolo_1,但是如果您注意到我使用的方法与您在文章中提到的方法相同,但是报告在运行时显示为空,尽管它在报告预览中返回数据,并且使用1st-way.rpt.SetDatabaseLogon(userId,userPassword);但是我需要在运行时更改dbconnection第二种方法是处理项目中的一些报告。。。它们之间唯一的区别是“不工作”报告中的子报告,尽管它在删除子报告后不工作