an error of report document object model
I created a report using report document object model in visual studio 2008 with vb开发者_JAVA技巧.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.
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
精彩评论