We help IT Professionals succeed at work.

Creating a reportviewer with multiple of same report sequentially

92 Views
Last Modified: 2018-12-30
Hello,

I'm trying to load multiple results into a reportviewer.  I'm having the user select multiple rows in a datagridview then click a button to load those into a reportviewer form.  It works fine for a single event and associated sub table data.  I envision having the reports sequentially page after page but I'd also be fine if it opened up multiple reportviewer forms ready for printing or saving.  I'd have to limit the total number of openable events I suppose, otherwise a user could open hundreds and that would bog down or fail but that should be easy.  

I played around with a query to capture all the events by serialno using an IN statement in the query builder for the dataset, but I kept getting an error and the reportviewer may not be able to handle it anyways so I thought I would ask before spending too much time on that.

Here's my attempted code that opens only the last selected event in the reportviewer:

       Dim selectedRowCount As Integer = Form1.dgResults.Rows.GetRowCount(DataGridViewElementStates.Selected)
        Dim SerialNo As Integer = Nothing

        For i = 0 To selectedRowCount - 1
            SerialNo = Form1.dgResults.SelectedRows(i).Cells("SerialNo").Value
            Debug.Print(RecordSerialNo)
            Try
             
               
                Me.IAdapter.Fill(Me.DataSet1.I, SerialNo)
                Me.pAdapter.Fill(Me.DataSet1.p, SerialNo)
                Me.vAdapter.Fill(Me.DataSet1.v, SerialNo)
                Me.cAdapter.Fill(Me.DataSet1.c, SerialNo)
                Me.uAdapter.Fill(Me.DataSet1.u, SerialNo)
            Catch ex As Exception
                LogIt(System.Reflection.MethodBase.GetCurrentMethod.Name.ToString & vbCrLf & "  ERROR: " & ex.Message.ToString)
                MsgBox(ex.ToString, , "Error with loading data.   ")
            End Try

        Next
        Me.ReportViewer1.RefreshReport()

Open in new window

Comment
Watch Question

Mike McCrackenSenior Consultant
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2013

Commented:
What reporting tool are you trying to use?

mlmcc

Author

Commented:
Just an RDLC based on a dataset in a reportviewer form.  Winforms 2010 V.S.
Mike McCrackenSenior Consultant
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2013

Commented:
I can't help you with that one, sorry

mlmcc

Author

Commented:
Anyone?  

Someone must have wanted to create a series of individual RDLC reports and either printed or saved them simultaneously.  Perhaps looping through them and programmatically saving or printing as desired by the user?  How to do this on an opened reportviewer?

Author

Commented:
I tried following this walkthrough with no luck:

https://msdn.microsoft.com/en-us/library/ms252091.aspx

and numerous pages that referenced this walkthrough.  Still getting errors on my datasets/tables when it comes time to render report.
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION