Reputation: 1534
Now I've been looking here including a few answers in here for the same question but none really solved the problem or contained enough info to clarify a few information.
Now first of all I made a .rdl report that connects to an access database. All good so far. Now I want to connect it with my software without a server (local) looked up the codes and the closest I got something to work is this:
Private Sub GenerateLocalReport()
ReportViewer1.ProcessingMode = ProcessingMode.Local
ReportViewer1.LocalReport.ReportPath = "D:\work\OrdersInvoice\ReportInvoice\ReportInvoice\OrdersReport.rdl"
reportViewer.RefreshReport()
ReportViewer1.RefreshReport()
End Sub
Now the issue is that the above code doesn't work. I get the following message: A data source instance has not been supplied for the data source.
Through searching what I found is that I needed to add something as a databinding. Now here is where the confusion begins.
Dim ds = New ReportDataSource("DataSet1",???)
reportViewer1.LocalReport.DataSources.Add(ds)
this is the most direct code I could get. But I have no idea what they mean by binding datasource. I tried to create a datasource in the program but its not the real answer. I am kinda lost here.
One other code I found which should do the same is:
ReportViewer1.LocalReport.DataSources.Add(TempDBDataSet.OrderTableDataTable
again same issue
Answers in either C# or VB.net are fine.
Upvotes: 1
Views: 933
Reputation: 1534
I believe I solved this issue after some trial and error. First of all here is the code I used:
Dim dataset As New DataSet("DataSet1")
Dim Conn As OleDb.OleDbConnection = New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\TempDB.mdb;User Id=admin;
Password=;")
Dim Adb As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter("Select * from OrderTable", Conn)
Adb.Fill(dataset)
Dim rds As New ReportDataSource()
rds.Name = "DataSet1"
rds.Value = dataset.Tables(0)
ReportViewer1.LocalReport.DataSources.Add(rds)
So what I did was that I made a connection to the database that was connected to the report and Then filled Data from the database to my dataset, Used that to access a table which I ended up referencing for the ReportDataSource.
After that it worked pretty well.
Upvotes: 1
Reputation: 5689
There are two types of Reporting Services files: RDL & RDLC.
Both function very similar.
RDL files are designed to run on a reporting server, where the server takes care of creating and filling the data source based on the connection info provided in the report.
RDLC files are designed to be embedded into your client applications, using a report viewer control, with no server required. You also have to connect and fill your data sources manually in your client application (as you are doing in your answer).
Upvotes: 1