Showing posts with label Reporting Services. Show all posts
Showing posts with label Reporting Services. Show all posts

Tuesday, August 5, 2008

ReportViewer changes application path once report exported (WinForm)

Apparently a bug, when a report is exported on a winform using the ReportViewer control, it changes the path for the application. If application tries to access any local files then it will look in the directory where the report was exported.

Solution is to save the path before the reportviewer is displayed and change it back to application path when the form is closed. The following two events worked in my case.

Dim _AppDirectory As String

Private Sub ReportViewerForm_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed

Environment.CurrentDirectory() = Me._AppDirectory


End Sub


Private Sub ReportViewerForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Me._AppDirectory = Environment.CurrentDirectory()


End Sub



Link:
http://forums.msdn.microsoft.com/en-US/vsreportcontrols/thread/d5d5e224-f906-4c3f-88e0-258ee2b2e149/

Reusing ReportViewer WinForm

Spent sometime figuring out that you can't use multiple Reporting services report unless you call the reset method of ReportViewer.

Link:
http://forums.msdn.microsoft.com/en-US/vsreportcontrols/thread/b039e765-3cc8-43ec-ae67-14b9656bc981/

Quote:

The key is to use the Reset method of ReportViewer.

ReportViewer1.Reset();

I put it above the LocalReport datasource clear/add and it worked!