Crystal Reports 数据库登录失败

发布于 2024-09-01 07:51:08 字数 1390 浏览 2 评论 0原文

在花了 3 到 4 个小时在谷歌上试图找到解决我的问题的方法之后,我运气不佳。

基本上,我们将水晶报表用于具有 SQL 服务器后端的 .NET 应用程序,我们有许多客户端,每个客户端都有自己的服务器,因此我们的报表需要动态设置它们的连接。直到一周前,这种方法还运行良好。然而,几天前,一位客户报告说,他们收到了报告的数据库登录提示(只有一份报告,其余的工作正常)。我们很困惑,但我们设法在没有安装 Visual Studio 或 SQL Server 的上网本上重现它。最后,开发人员决定重现该报告,希望这只是该特定报告中的一个奇怪现象。

不幸的是,今天的一个新客户也遇到了同样的问题,但这一次他们拥有的每一份水晶报告 - 而且他们也在上网本上工作,所以我们真的很迷失在这里。

以下是我们的客户收到的屏幕截图 -

屏幕截图

这是我用来在报告中设置连接信息的代码

                cI.ServerName = (string)builder["Data Source"];
                cI.DatabaseName = (string)builder["Initial Catalog"];
                cI.UserID = (string)builder["User ID"];
                cI.Password = (string)builder["Password"];

                foreach (IConnectionInfo info in cryRpt.DataSourceConnections)
                {
                    info.SetConnection(cI.ServerName, cI.DatabaseName, cI.UserID, cI.Password);
                }

                foreach (ReportDocument sub in cryRpt.Subreports)
                {
                    foreach (IConnectionInfo info in sub.DataSourceConnections)
                    {
                        info.SetConnection(cI.ServerName, cI.DatabaseName, cI.UserID, cI.Password);
                    }
                }

一如既往,非常感谢任何帮助。

After spending a good 3 to 4 hours on google trying to find any solution to my problem I haven't had much luck.

Basically, we use crystal reports for our .NET applications with a sql server back end, we have many clients each with their own server and so our reports need to have their connections dynamically set. Up until a week ago this worked fine. However a few days ago a client reported they were getting a database login prompt for a report (only one report, the rest worked fine). We were quite stumped but we managed to reproduce it on a netbook which didn't have visual studio or sql server installed. In the end the dev decided to reproduce the report in the hope it was just an oddity in that particular report.

Unfortunately a new client today also experienced the same problem, but this time for every crystal report they had - and also they worked on the netbook, so we are really quite lost here.

Below is a screenshot of what our clients get presented with -

Screenshot

and here is the code that I use to set the connection information in the report

                cI.ServerName = (string)builder["Data Source"];
                cI.DatabaseName = (string)builder["Initial Catalog"];
                cI.UserID = (string)builder["User ID"];
                cI.Password = (string)builder["Password"];

                foreach (IConnectionInfo info in cryRpt.DataSourceConnections)
                {
                    info.SetConnection(cI.ServerName, cI.DatabaseName, cI.UserID, cI.Password);
                }

                foreach (ReportDocument sub in cryRpt.Subreports)
                {
                    foreach (IConnectionInfo info in sub.DataSourceConnections)
                    {
                        info.SetConnection(cI.ServerName, cI.DatabaseName, cI.UserID, cI.Password);
                    }
                }

As always, any help much appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

青衫负雪 2024-09-08 07:51:08

Perhaps the issue is the way that you set the authentication information. Have you considered using the ReportDocument.SetDatabaseLogon method? Call it once for each unique DB connection in the report. It will eliminate the need to enumerate all of the tables in the report and, as I recall, the need to enumerate the subreports' tables as well.

难理解 2024-09-08 07:51:08

解决方案发现,事实证明,客户端用于设置系统的连接生成器没有将实例名称放入其中。令人困惑的是,.net 应用程序可以很好地处理它。然而,经过排序的水晶报告现在可以完美地工作。

感谢您的投入,克雷格。

Solution found, it turned out the connection builder that client used to set up their system did not put the instance name in. Rather confusingly the .net app worked fine with it like that. However, with that sorted crystal reports now work flawlessly.

Thank you for your input Craig.

很糊涂小朋友 2024-09-08 07:51:08

寻找类似问题的解决方案使我想到了这个问题。我的问题/解决方案有点不同,但我猜其他有我问题的人会在这里结束,所以我将在这里发布我的解决方案。

如果您的用户在尝试预览报表时看到类似的内容:

Crystal Reports Viewer screen shot

然后在设置 SQL Server 时报告的登录信息,请确保包含服务名称。因此,例如,请确保您为 Crystal 提供“myserver\myservice”,而不仅仅是“myserver”。

我的程序能够仅使用“myserver”从 SQL Server 访问数据,但需要为 Crystal 提供“myserver\myservice”。

Searching for a solution to a similar problem brought me to this question. My problem/solution was a little different but I'm guessing others with my problem will end up here so I'll post my solution here.

If your users are seeing something like this when trying to preview a report:

Crystal Reports Viewer screen shot

then when setting the SQL Server login info for the report, make sure you include the service name. So, for example, make sure you're giving Crystal "myserver\myservice" instead of just "myserver".

My program is able to access data from SQL Server using just "myserver", but Crystal needs to be given "myserver\myservice".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文