0

I have a simple vb.net app.

Module Module1
    Sub Main()
        ' Two DataTables.
        Dim table1 As DataTable = New DataTable("patients")
        table1.Columns.Add("name")
        table1.Columns.Add("id")
        table1.Rows.Add("sam", 1)
        table1.Rows.Add("mark", 2)

        Dim table2 As DataTable = New DataTable("medications")
        table2.Columns.Add("id")
        table2.Columns.Add("medication")
        table2.Rows.Add(1, "atenolol")
        table2.Rows.Add(2, "amoxicillin")

        ' Create a DataSet. Put both tables in it.
        Dim set1 As DataSet = New DataSet("office")
        set1.Tables.Add(table1)
        set1.Tables.Add(table2)

    End Sub
End Module

I would like use RDL or RDLC to display one of the table in my dataset (set1). Can I do that? if yes, how can I do it??

I want (or I am hoping) to run RDL or RDLC without the need of having a SQL connection or Access MDB Database, nor intermediary XML or CSV file in file system..

thank you for reading my question.

BobNoobGuy
  • 1,551
  • 2
  • 30
  • 62
  • 1
    There are a number of similar questions on this site, including one I wrote a year ago, https://stackoverflow.com/q/47515189/5162073. My previous answer seems to be what you're looking for. – Brian M Stafford Dec 05 '18 at 21:28
  • thanks! Let me look into it – BobNoobGuy Dec 05 '18 at 22:32
  • mmm I know my one of my column is "Name". But how can I design that in the RDLC if I don't have a dataset? – BobNoobGuy Dec 05 '18 at 23:00
  • This is my VB.net code. https://i.imgur.com/kP6rWS8.png and this is my RDLC https://i.imgur.com/DUXYKTK.png. My confusion is now how can I add the field in the RDLC since I cannot manually type in the field name – BobNoobGuy Dec 05 '18 at 23:17

1 Answers1

0

Finally I got it working.

I was missing this step to add xsd. see screenshot below.

So this is my final code ANOTHER IMPORTANT POINT IS THE DATATABLE in XSD must be the same name as your DATATABLE build in the form_load

Imports Microsoft.Reporting.WinForms

Public Class Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        Dim DataTable1 As DataTable = New DataTable("patients")
        DataTable1.Columns.Add("name")
        DataTable1.Columns.Add("id")
        DataTable1.Rows.Add("sam", 1)
        DataTable1.Rows.Add("mark", 2)


        ReportViewer1.LocalReport.ReportPath = "C:\IT\MISC\Visual Studio Project PLAYGROUND\WinFormPlay\Report\Report1.rdlc"


        ReportViewer1.LocalReport.DataSources.Add(New ReportDataSource("DataSet1", DataTable1))

        Me.ReportViewer1.RefreshReport()


    End Sub

End Class

enter image description here

BobNoobGuy
  • 1,551
  • 2
  • 30
  • 62