none
VB.net 2012 DataTable to ReportViewer without SQL RRS feed

  • Question

  • Hi Guys

    I've been working on a small application that scans some log files and presents them in a DataGridView...

    I've now been requested if they can be presented in a ReportViewer so that the user can print the data out with headers etc.

    Trouble is this all needs to be achieved programmatically as the log files are all generated from a variety of different applications each of which can be user configurable to place the data in different orders or contain different data see bellow...

    [ID][TYPE][DATE][TIME][NODE][VALUE]

    [TIME][DATE][NODE][SUBNODE][VALUE][ID][TYPE][DESCRIPTION]

    I currently have custom loading functions that parse the log files and place the data into set columns in a DataTable at the moment, this can load multiple files and eventually end up with over 20k records so DataGridView gets very slow at updating.

    It's been suggested that I use a ReportViewer instead and by using ComboBoxes I can filter out items by Date, Time, Type etc.

    Now the hard bit, no matter how I go about this, I cant get the ReportViewer to display anything? I'm currently using the following code which is what appears everyone is using to achieve the desired result, all I get is a blank screen?

    rv_Reports.LocalReport.DataSources.Clear()
    Dim _rvDt As ReportDataSource = New ReportDataSource(g_DataTable.TableName, g_DataTable)
    rv_Reports.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Local
    rv_Reports.LocalReport.EnableExternalImages = True
    rv_Reports.LocalReport.DataSources.Add(_rvDt)
    rv_Reports.RefreshReport()
    

    I've tried creating Report.rdlc's 'not quite sure how to get these to work with dynamic content' or for that mater how to populate the items I put in them?

    An additional requirement is, depending on the [TYPE] specified within the log file and selected from the ComboBox, the report would be required to display different contents! i.e.

    a log type of OC 'Operator Change' would display DATE, TIME, USER & VALUE where a log type of ALM 'Alarm' would display DATE, TIME, ALARM TYPE, VALUE, DESCRIPTION

    Finally an additional requirement is to minimise the amount of additional software as this will be running on several different embedded systems not running any ACCESS, ODBC, SQL or ORACLE databases, these standalone systems just generate text based (sometimes csv) log files, the application is just to present these logs in a user friendly format.

    I'm looking for a simple tutorial, that details everything required to get data from a datatable to display on a reportviewer all the examples I've tried so far all go into SQL or other methods which isn't what I'm wanting?

    Thanks in advance for any help getting this working

    Monday, November 13, 2017 10:13 AM

All replies

  • Hi,

    Thanks for posting in SharePoint, Apps for Office and SharePoint  >  Developing Apps for SharePoint 2013.

    This forum is for users discussing issues involve SharePoint 2013, Since the issue is more relative to VB.Net, I would move it to Visual Studio Languages  >  Visual Basic forum.

    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge.

    Thanks for your understanding.

    Best Regards,

    Lee


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Tuesday, November 14, 2017 2:31 AM
  • Thanks Lee

    I Don't know how it ended up in there, I was looking at the VB.Net forum at the time?

    Tuesday, November 14, 2017 10:08 PM
  • Hi friend,

    >> I'm currently using the following code which is what appears everyone is using to achieve the desired result, all I get is a blank screen?

    I find a similar link as this issue, please refer to it as below:

    how to set Datatable as datasource in ReportViewer.

    Also: C# - binding datatable to reportviewer

    Regards,

    Stanly


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, November 16, 2017 6:53 AM
  • Hi Stanly

    Unfortunately I had already found this page, but it's code doesn't appear to work.

    It is similar to my code sample above which was created from a selection of code samples like the one you suggested.

    It appears what should be a straightforward task as in DataTable to DataGridView, DataTable to ReportViewer has everyone stumped...

    Thursday, November 16, 2017 8:28 PM
  • Hi Alan,

    Sorry for the late reply.

    Please refer to the following steps:

    1, Add a report to your project(then move the report to: ...\bin\Debug\Report1.rdlc):

    2, Add a dataset to the project:

    3, Drag a DataTable to the dataset and add some fields:

    4, Drag a table to the report interface:

    5, Then the code:

    Private Sub Form1_Load(sender As Object, e As EventArgs)
    	Dim dt As New DataTable()
    	Dim rds As New ReportDataSource("DataSet1_DataTable1", dt)
    	Dim startupPath As String = Environment.CurrentDirectory
    	reportViewer1.LocalReport.ReportPath = startupPath & Convert.ToString("\Report1.rdlc")
    	reportViewer1.LocalReport.DataSources.Add(rds)
    	reportViewer1.RefreshReport()
    	'this.reportViewer1.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.PrintLayout);            
    End Sub

    Regards,

    Stanly


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, November 21, 2017 8:06 AM