报告文档对象模型错误
我使用 Visual Studio 2008 中的报告文档对象模型和 vb.net 创建了一个报告。但我发现一个错误。当用户单击客户端的导出按钮时,将显示以下错误。但在用户单击导出按钮之前第一次是可以的。
Logon failed. Details: ADO Error Code: 0x Source: Microsoft OLE DB Provider for SQL Server Description: Login failed for user 'zanhtet'. SQL State: 42000 Native Error:
这是调用报告代码。
Dim ReportDocument As New ReportDocument()
Dim ReportPath As String = Server.MapPath("~/ReportDocumentOM/DBlogInRDOM.rpt")
ReportDocument.Load(ReportPath)
ReportViewer.ReportSource = ReportDocument
Dim ConnectionInfo As New ConnectionInfo
ConnectionInfo.ServerName = "ZANHTET\SQLEXPRESS"
ConnectionInfo.DatabaseName = "EAS_DevTrack4UDev"
ConnectionInfo.UserID = "zanhtet"
ConnectionInfo.Password = "123456"
For Each Table As Table In ReportDocument.Database.Tables
Dim TableLogOn As TableLogOnInfo = Table.LogOnInfo
TableLogOn.ConnectionInfo = ConnectionInfo
Table.ApplyLogOnInfo(TableLogOn)
Next
我该如何解决这个问题。请帮我。
I created a report using report document object model in visual studio 2008 with vb.net. But I found one error. When the user clicks export button in client side, the following error will show. But the first time is OK before the user clicks export button.
Logon failed. Details: ADO Error Code: 0x Source: Microsoft OLE DB Provider for SQL Server Description: Login failed for user 'zanhtet'. SQL State: 42000 Native Error:
This is calling report code.
Dim ReportDocument As New ReportDocument()
Dim ReportPath As String = Server.MapPath("~/ReportDocumentOM/DBlogInRDOM.rpt")
ReportDocument.Load(ReportPath)
ReportViewer.ReportSource = ReportDocument
Dim ConnectionInfo As New ConnectionInfo
ConnectionInfo.ServerName = "ZANHTET\SQLEXPRESS"
ConnectionInfo.DatabaseName = "EAS_DevTrack4UDev"
ConnectionInfo.UserID = "zanhtet"
ConnectionInfo.Password = "123456"
For Each Table As Table In ReportDocument.Database.Tables
Dim TableLogOn As TableLogOnInfo = Table.LogOnInfo
TableLogOn.ConnectionInfo = ConnectionInfo
Table.ApplyLogOnInfo(TableLogOn)
Next
How can I solve this. Please, help me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定你上面的代码是在什么地方调用的。但如果您还没有这样做,请处理来自报表查看器的重要事件。在这些事件处理方法中,请确保再次调用此身份验证代码。
导出相关事件应该会给你带来好运,但你可能还必须处理其他几个事件(就像分页一样,我也遇到了类似的问题)。
请参阅此处了解报表查看器事件
http://msdn .microsoft.com/en-us/library/microsoft.reporting.winforms.reportviewer.reportexport.aspx
I am not sure your code above is invoked at what place. But if you are not already doing this, then handle important events from reportviewer. Inside those event handling method, make sure you invoke this authentication code again.
Export related event should do you a luck but you may have to handle couple of others as well (like for pagination also i had similar issues).
See here for Report Viewer Events
http://msdn.microsoft.com/en-us/library/microsoft.reporting.winforms.reportviewer.reportexport.aspx