Hello everyone. I would like to ask for your help, I've been stuck in this problem for wholde day. every time I run this code it gives me an error of "The report has no tables" even though I have a dataset. my dataset is datatable that came from the data from my listview. Here is my code:
If ListView1.Items.Count <= 0 Then
' do nothing here
Else
'print the number of item in listview
MsgBox(ListView1.Items.Count)
Dim mytable As DataTable = New DataTable("Employeelogs")
' create static field from column name = <fieldname> ... </fieldname>
mytable.Columns.Add("field1")
mytable.Columns.Add("field2")
mytable.Columns.Add("field3")
mytable.Columns.Add("field4")
mytable.Columns.Add("field5")
For i = 0 To ListView1.Items.Count - 1 Step 1
Dim li = ListView1.Items(i)
mytable.Rows.Add(li.Text, li.SubItems(1).Text, li.SubItems(2).Text, li.SubItems(3).Text, li.SubItems(4).Text)
Next
Dim ds As DataSet = New DataSet("mydataset")
ds.Tables.Add(mytable)
'this msgbox is to display the number of logs row
MsgBox(ds.Tables("logs").Rows.Count)
'for checking only - display xml table
Console.WriteLine(ds.GetXml())
Dim objRpt As New testreport
objRpt.SetDataSource(ds.Tables("logs"))
postreport.Show()
postreport.CrystalReportViewer1.ReportSource = objRpt
postreport.CrystalReportViewer1.Refresh()
ds.Dispose()
ds = Nothing
End If