I'm trying to create a report in my application. I've added a DataSet component to my application and I'm trying to query some data from DB and load it into that Data set to be used in my report.Here's what I'm doing (basically calling a function depending on previous parameter)
Private Sub GrabReportData(ByVal RepNo As Integer)
Conn.Open()
Dim adapter As SqlDataAdapter
Dim reportDataset As DataSet
Dim sql As String = "SELECT FirstName, LastName from tblCustNotes"
adapter = New SqlDataAdapter(sql, Conn)
adapter.Fill(reportDataset, "DataTable1")
End Sub
I added a DataTable1 here but when I run this code I get this error....
Value cannot be null.
However I know for a fact that I have data in there.
I'm hoping to be able to Populate the ReportDataSet component and use it as datasource for my reports. First time doing this, struggling a bit. I'm more of a MS Access person :/
EDIT:
Per @Plutonix did this...
Deleted ReportDataSet component
Dim reportDataset As New DataSet
Dim sql As String = "SELECT FirstName, LastName from tblCustNotes"
Using adapter As SqlDataAdapter = New SqlDataAdapter(sql, Conn)
adapter.Fill(reportDataset, "DataTable1")
ReportViewer1.LocalReport.DataSources.Clear()
ReportViewer1.LocalReport.DataSources.Add(reportDataset.tables(0))
End Using
