I'm a seasoned MS Access developer trying to learn C# and I'm finding formatting reports to be really difficult compared to how easy MS Access is.
I couldn't get anything useful out of the report wizard, but I've now got my head around creating a report manually. So ok I now have a basic report showing a customer listing, with a title in the page header section.
So now what I want to do is change the title at runtime. For example if I filter the dataset to only show UK customers who have bought goods this year, I want to change the title in order to explain what is being listed: "UK Customers who bought goods this year".
In MS Access I can use the report pageheader OnFormat event to do things like this. Can this be done in C#?
I've managed to sort this out myself. In the DataSet for my Report I added a column to the TableAdapter query. Select #Title as Title, Customers.CustomerCode etc... In the Report I added a TextBox for the Title and bound it to the title field in the dataset. Then when my report opens, I can supply the title as a parameter when the DataSet Table is filled.
Reporting Services uses visual basic for the expression language, so you can set the title to something like ="foo #" & (3+3) to get a value of "foo #6". Additionally, you can use parameters as you mentioned in your answer by setting the title to =Report.Parameters!Title.Value (assuming you have a parameter named "Title").
If you'd like to use C#, then unfortunately you can only do this via a custom assembly, which is not the easiest thing in the world to get set up.
For more information on embedding code in a SSRS report, take a look at this page on MSDN: https://msdn.microsoft.com/en-us/library/ms159238(v=sql.120).aspx
Related
I have searched and searched and have not been able to find the answer to this. I'm no stranger to SSRS, .Net (c# and vb.net), SQL, etc...been in it for years. I currently have a multi-select report parameter that is populated by a dataset in my report. There are hundreds of entries, so I built it to be driven by a wildcard character in a preceding parameter. Everything works fine right now. My question is this: is it possible to enter a wildcard value, select one (or more) of the filtered values and then store that/those value(s) on selection so that a user can go back and enter another wildcard value and select from a newly filtered list? (Basically, remember what has been selected in the overall dataset before report execution and create some sort of comma-separated list as the final parameter value to be passed to the report) I realize this may be better served in a web app w/a reportviewer control, but I'm trying to avoid deviating from the native SSRS server if possible. Thanks in advance!
The way I might approach this (not actually done it but the theory sounds ok)
Have 2 parameters for user input, your current one and a hidden one called say #filter (visible) and #filterHistory (this is the hidden one)
Have a textbox (formatted like button) with something like "Refine" as the text. Set the action to call your report again but set the #filterHistory to be something like #filterHistory & ", " & #filter. Basically we keep appending the last user input to the history.
Then your report would filter based on both parameters. You'll have to do some parsing of the delimited parameter now to split it out into the constituent parts but you get the idea.
I've no time to build a test report but hopefully that will point you in the right direction. If it doesn't help or work then comment and I'll see if I can knock up a quick example.
I am creating a desktop, C# application in Lightswitch. I have a DB file with a table called Reports and another table called StatusList. There are going to be 3 options in StatusList table - Unresolved, In Progress and Resolved. The Report table has a couple of not important fields and a field "Status", which is supposed to hold one of the three values from StatusList table
Now, when the user will create a new Report, I need the application to automatically insert the "Unresolved" value as the "Status" without user being able to change it.
I have tried using this method
partial void Reports_Created()
{
this.Status = "Unresolved";
}
but it is not working. I guess it is because I am trying to assign a String value to the field which is populated from another table.
I am using Visual Studio 2013 and this is my first Lightswitch app as well.
Thank you in advance for any help.
It sounds like your trying to pass parameters between screens. Beth Massi does a good job explaining how to achieve that in this video. And here is another MSDN link to a similar question
Shouldn't your code before like:
This.report.status = "Unresolved"
I.e. The report entity is not referenced by "this" (that refers to the screen).
I am trying to learn how to use reportviewer in VS 2013. I know how to add a report and load it up with data but I am trying to add a parameter. The MS Access database contains one table called BasicForm and has 4 fields ID, firstName, lastName, and note.
this.BasicFormTableAdapter.Fill(this.FormFillDBDataSet.BasicForm);
this.reportViewer1.RefreshReport();
this is the code to load the report. Now according to YouTube Instruction I have to enter this SQL syntax.
SELECT BasicForm.ID, BasicForm.firstName, BasicForm.lastName, BasicForm.note
FROM BasicForm
WHERE BasicForm.firstName=#x
Then I have to enter to go back to code where I load up the report and enter the string that would be the value of parameter, as written below:
this.BasicFormTableAdapter.Fill(this.FormFillDBDataSet.BasicForm, "Gaston");
this.reportViewer1.RefreshReport();
but it does not work because VS will give me a SQL syntax error so I changed it as such:
SELECT BasicForm.ID, BasicForm.firstName, BasicForm.lastName, BasicForm.note
FROM BasicForm
WHERE BasicForm.firstName=[x]
Just as I would write it in MS access and it would work but then when I went back to the code to add the string that would be the value of the parameter, VS would give me an error message of unknown method. I am sure I am writing the syntax wrong but I am new to c# so no idead how to rewrite it the correct way.
Thank you for helping
I have a table Called EmployeeTypes which hold types of Employees, now i want to create a report using SSRS which will have something like this:
EmployeeType1 EmployeeType2 EmployeeType3
4 23 2
where the numbers are the count of employees.
problem is how can i generate the columns programmatically like that as the EmployeeTypes Table can have many Types and expand by time?
It sounds like you are looking for a cross tab report, using a data set like select count(*), employee_type from employee_table group by employee_type.
You can use the report wizard to create a 'Matrix' report type (as opposed to a 'Tabular' report type). The wizard will guide you through the steps to get what you need.
An SSRS report is defined by an XML file (the .RDL or .RDLC file). You could generate columns programmatically by directly modifying the XML. Not for the faint of heart, but people do it, and it can be done.
Here is a sample:
http://www.codeproject.com/Articles/11254/SQL-Reporting-Services-with-Dynamic-Column-Reports
I want to programmatically change formulas in a whole lot of reports, like in this question, but I also need to change the formula between Crystal Syntax and Basic Syntax. I can't see any way to do this in the object model. Is it possible?
i.e. I have a formula called 'Period' that already exists in a whole lot of reports, and it's currently defined in Crystal Syntax. I want to set the formula to be in Basic Syntax and provide updated text of the formula. I don't need to automatically convert the current definition from crystal to basic; I already have the new formula text.
If I simply loop through all the reports, open them, then set the FormulaFieldDefinition's Text property then the formulas are still set to 'Crystal Syntax' and won't evaluate correctly. Currently my only solution is manually opening each report, editing the formula, changing the dropdown from Crystal Syntax to Basic Syntax.
this http://msdn.microsoft.com/en-us/library/ms225743%28VS.80%29.aspx says that formulas are supported with Crystal Syntax and Basic Syntax - doesn't it automatically accept both of them?
Or do you want to convert between these two syntaxes?
I believe and #CodeByMoonlight confirms that this isn't available. So for anyone in the same boat as me with many reports to update: enjoy that manual process and hope you never have to change back!
You can walk through the report objectmodel like this.
Just change the formula and formula name.
public ReportDocument GetReport(DataSet ds)
{
const string formula = "WhileReadingRecords;" +
"<<your formula>>";
ReportDocument report = new InvoiceReport();
report.SetDataSource(ds);
// iterate report objects
foreach (ReportObject ro in report.ReportDefinition.ReportObjects)
{
if ((ro.Kind == ReportObjectKind.FieldObject && ro.Name == "<<FormuleName>>"))
{
((FormulaFieldDefinition) ((FieldObject) o).DataSource).Text = formula;
}
}
return report;
}