Does VS 2017 allow two datasets for an rdlc report? - sql

I have a framework for my applications that hold reports that are printed from the application. I have one report that I'm trying to add a second dataset to but I keep getting the error "A data source instance has not been supplied for the data source 'DataSetTwo'". Is it impossible to add a second dataset to a report?
The reason I'm adding a second data source is I have one that will populate nearly all information on the report and then the second is going to be used for a tablix in the report. I can't use the first dataset because for some reason the group by is not working on the SQL statement so I'm going to add a new dataset with less fields so the group by isn't a problem.

The error
A data source instance has not been supplied for the data source 'DataSetTwo'
indicate you had not supply the data source.
When you generate the report, did you supply the second dataset?
It should look something like this:
ReportViewer.LocalReport.DataSources.Clear();
ReportDataSource rd1 = new ReportDataSource("DataSetOne", dataset1);
ReportDataSource rd2 = new ReportDataSource("DataSetTwo", dataset2);
ReportViewer.LocalReport.DataSources.Add(rd1);
ReportViewer.LocalReport.DataSources.Add(rd2);
ReportViewer.LocalReport.Refresh();

Related

Appending multiple instances of the same report together?

I have a report that basically is being used to populate textboxes using an sql query for a given order number. This generates the invoice well but i am now trying to see if its possible to rerun the same report with another order number through the sql query but append the new report onto the first one to basically have two concatenated instances of the report for export as a pdf. I've looked and the only thing ive found is using something like:
Dim reportinstance As New Report_Invoice
but i'm lost on how to repopulate the new instance with different data and append it together, any help is appreciated!
You can use the WHERE part of the report's parameters to do this. Something like:
Docmd.OpenReport "rptInvoice",acViewPreview,,"InvoiceID IN(1,4)"
This will open the report rptInvoice limited to show those that have an InvoiceID of either 1 or 4. You may need to build up the WHERE statement using VBA, perhaps from choices selected in a list box.

SSAS Tabular Model - Add column to existing table

I am using VS2019 for SSAS Tabular Model development. Have imported a table from a CSV. The source CSV has undergone a change(new column has been added). When I process my table in VS2019, it gets processed successfully. However I am unable to see the new column introduced in source CSV. I went to Table properties and did a Refresh Preview but was not able to see the new column. Closed and re-started solution, re-processed the table but no luck! I remember in VS2017 we used to add the column by going into table properties and selecting the new column but things seem to be different in VS2019. Any help would be appreciated.
I'm assuming you used Get Data / Power Query to import the CSV. This unfortunately generates a Power Query Csv.Document function call that includes the number of columns when the query was generated. This parameter isn't exposed through the usual Power Query UI.
If you use the Advanced Editor or turn on the Formula Bar (view menu), you will see a parameter like Columns=10, was generated, usually in your Source step.
It currently seems safe to delete that parameter by editing the code - it will then always pull back all columns presented. Or if you prefer, you can edit the number of columns, as described in this blog post:
https://prathy.com/2016/08/how-to-add-extra-columns-to-an-existing-power-bi-file-which-using-csv-data-source/

How to pass data from DataGridView to table in ReportViewer without Database or Dataset

I have a few DataGridView tables which user fills (I don't use any Dataset or Database here).
I need to pass them to ReportViewer, I want exact the same tables in report as in a form, no changes at all.
I tried something like this, but it's not working:
Dim rds As New ReportDataSource("rds1", Form1.dgv1.DataSource)
Me.ReportViewer1.LocalReport.DataSources.Add(rds)
and in report1.rdlc added a table and set it dataset name to rds1 but it generates error
The table ‘table1’ refers to an invalid DataSetName ‘rds1’.
So I guess I need to make a DataSet from my DataGridView tables.
How would you suggest me to do that? Otherwise, is there any simpler way to pass the table to report?
You should add a DataSet to your report .rldc Data Sources list and drag and drop the columns into your report element (table, tablix, list etc.)
Remember you can add any kind of object from your project to your report as Data Source (basically any Public Class you create). The imported names and types will be taken from the class properties.

SSRS report builder 2.0 store STATIC DATA to use to query results

Does any one know if there is a way to import a spreadsheet into report builder 2.0 and then use my data set to make calculations against.
This might seem like a novice question as my limited experience of report builder does not help.
The reason i want to do this is so that i don't have to have my main data-set run the query on working out averages of hundreds of thousands of records as it take ages to run. by having the benchmark average data static i would want to run my query and do the calculations in report builder which will make it a 100 times faster.
Thank you for your time in advance
You may be able to overcome this by adding Calculated Fields to your dataset (DS). I am assuming that your static data can be related to your dataset by using at least one existing field. Using the Switch function, you can populate your calculated fields. Switch “evaluates a list of expressions and returns an Object value corresponding to the first expression in the list that is True.”
You can use the function like this:
=Switch(Fields!DsField1.Value = 2, “Your Value1”, Fields!DsField1.Value = 5, “Your Value2”, Fields!DsField1.Value = 10, “Your Value3”, ….)
If you have any condition that needs to be checked, you can add it before the Switch statement like this:
=IIF(Fields!DsField20.Value <>1000, Switch(Fields!DsField1.Value = 2, “Your Value1”, Fields!DsField1.Value = 5, “Your Value2”, Fields!DsField1.Value = 10, “Your Value3”, ….), Nothing)
You can have your values in an Excel sheet to make the creation of the formula easier. Simply create your formula in the first row, copy the row down to extend your formula, and cover all your values. Then from Excel simply copy and paste the column of data into your calculated field(s).
Here’s an example of My Excel formula. This is the best I could do as I could not paste the sample here. You can copy and paste these and replace them your own values.
In Cell-A2 2
In Cell-B2 YourValue1
In Cell-C2 YourOtherValue1
In Cell-D2 YourOtherOtherValue1
In Cell-E2 YourOtherOtherOtherValue1
In Cell-F2 ="Fields!DsField1.Value ="&A2&","&""""&B2&""""&","
In Cell-G2 ="Fields!DsField1.Value ="&$A2&","&""""&C2&""""&","
In Cell-H2 ="Fields!DsField1.Value ="&$A2&","&""""&D2&""""&","
In Cell-I2 ="Fields!DsField1.Value ="&$A2&","&""""&E2&""""&","**
Sorry if there is anything I have missed; I did this in a rush.
Report builder doesn't have anywhere you can 'import' the spreadsheet to, except one of the databases you are querying from. And Excel isn't a supported data source for SSRS, however it might be possible to add a report data source that uses an ODBC DSN to the appropriate Excel file. (I haven't tried it).
But, I can foresee some problems with this approach - it may get upset under multiple users and I expect you may find the file gets locked so you can't update it very easily.
An approach that might work could be to upload the static data into an Access database (as that is supported via the OLE DB Jet provider) and reference that as a data source; but the best approach is always going to be importing the static data into a table in your main database and using that.

Binding DataSet to RDLC

I am creating rdlc report(not using reportviewer, using report template). I have a business class which has a code for getting dataset by calling stored procedure. I am binding that dataset to rdlc report using ReportDataSource class. How to access this dataset in design?
In rdlc xml file, I tried to add dataset and it fields, it works fine if the columns are constant. I have a dataset it returns a datatable which has variable number of columns depending on user selection, will get to know number of columns at run time, that dataset I want to assign to table or any control in rdlc design. How can I do that?
Thanks,
Megha