Microsoft ReportViewer 控件只读

发布于 2024-10-18 10:25:17 字数 365 浏览 1 评论 0原文

我最近在属于 Microsoft.Reporting.WebForms 命名空间的网页上成功使用了 Microsoft ReportViewer 控件。我使用 ReportViewer 的一个名为 Server.ReportServerCredentials 的属性来设置凭据(域、用户和密码)。我已经能够显示远程服务器上的报告。

现在,我需要做类似的事情,但我需要 Windows 窗体中的报告。我遇到的问题是我正在使用属于 Microsoft.Reporting.WinForms 命名空间的控件,并且属性 ReportServerCredentials 是只读的。

为什么对于一个控件来说,该属性是只读的,而另一个控件则没有考虑到您需要设置访问报表的凭据?我该如何解决这个问题?

I successfully used the Microsoft ReportViewer Control on a webpage recently belonging to the Microsoft.Reporting.WebForms namespace. I used a property of the ReportViewer called Server.ReportServerCredentials to set the credentials (domain, user and password). I've been able to display reports which are on a remote server.

Now, I need to do something similar but I need the report in a windows form. The problem I'm having is that I'm using the control belonging to the Microsoft.Reporting.WinForms namespace and the property ReportServerCredentials is READONLY.

Why is it that for one control this property is readonly and the other not considering you need to set the credentials to access the report? How do I work around this?

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

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

发布评论

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

评论(3

忘你却要生生世世 2024-10-25 10:25:17

它实际上不是只读的。

检查 MSDN - ReportServerCredentials 类< /a>.

以下是设置凭据的方法。

ReportServerCredentials reportCredentials = new ReportServerCredentials();
//SET THE CREDENTIALS HERE A LA reportCredentials.ImpersonateUser etc.
rvReportViewerControl.ServerReport.ReportServerCredentials = reportCredentials;

编辑:

ReportViewer1.ServerReport.ReportServerCredentials.NetworkCredentials = reportCredentials.NetworkCredentials;

It's actually not read only.

Check MSDN - ReportServerCredentials class.

Here's how you would set the credentials.

ReportServerCredentials reportCredentials = new ReportServerCredentials();
//SET THE CREDENTIALS HERE A LA reportCredentials.ImpersonateUser etc.
rvReportViewerControl.ServerReport.ReportServerCredentials = reportCredentials;

Edit:

ReportViewer1.ServerReport.ReportServerCredentials.NetworkCredentials = reportCredentials.NetworkCredentials;
别挽留 2024-10-25 10:25:17

这本身并不能真正回答您的问题,但我会跳过使用 WinForms 报告查看器。请参阅我的答案此处了解原因以及如何更好地做到这一点Web 浏览器(您甚至可以利用已访问报告的 Web 应用程序)。

This doesn't really answer your question per se, but I would skip using the WinForms report viewer. See my answer here for why, and how to do it a better way with a web browser (you could even leverage your Web app that already accesses the reports).

菊凝晚露 2024-10-25 10:25:17

使用此代码

dim myCred As NetworkCredential = New NetworkCredential("mmmmmm", "*****", "----")
ReportViewer1.ServerReport.ReportServerCredentials.NetworkCredentials = myCred

与 Webforms 版本的 ReportViewer 控件要求您提供 IReportServerCredentials 接口的实现不同,winforms 版本的报表查看器实现 ReportServerCredentials< /code> 直接。在您的情况下,您只需将 NetworkCredential 对象分配给 ReportViewer.ServerReport.ReportServerCredentials.NetworkCredentials 即可。

Ue this code

dim myCred As NetworkCredential = New NetworkCredential("mmmmmm", "*****", "----")
ReportViewer1.ServerReport.ReportServerCredentials.NetworkCredentials = myCred

Unlike the webforms version of the ReportViewer control which requires you to provide an implementation of the IReportServerCredentials interface, the winforms version of the report viewer implements ReportServerCredentials directly. In your case, you can just assign your NetworkCredential object to ReportViewer.ServerReport.ReportServerCredentials.NetworkCredentials.

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