2011-04-28 31 views
0

我使用vb.net在visual studio 2008中使用報告文檔對象模型創建了一個報告。但是我發現了一個錯誤。當用戶單擊客戶端的導出按鈕時,將顯示以下錯誤。但在用戶點擊導出按鈕之前,第一次是確定的。報告文檔對象模型的錯誤

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 

我該如何解決這個問題。請幫幫我。

+0

我假設,如果你與所示憑證上面它的工作原理,直接連接到數據庫? – Ben 2011-04-28 10:55:53

+0

是的,這是工作。 – zanhtet 2011-04-29 02:13:52

回答

2

我不確定上面的代碼是在什麼地方調用的。但是,如果您尚未執行此操作,請處理來自reportviewer的重要事件。在這些事件處理方法中,請確保您再次調用此驗證碼。

出口相關的事件應該是你的運氣,但你可能需要處理其他幾個人(如分頁也有類似的問題)。

在這裏看到報表查看活動

http://msdn.microsoft.com/en-us/library/microsoft.reporting.winforms.reportviewer.reportexport.aspx