I have more that 50 reports in my project hence i cannot opt to pass currency symbol to each and every report individually hence i am exploring an alternative to it, i have already set culture symbol to what i need but i am unable to set my crystal reports to accept that symbol.
for your better understanding i have a field in my db that accepts currency symbol and i have set current culture currency symbol to that value but i am unaware of how to set all my crystal reports to accept that value as my default currency symbol, also i would like to request a detailed step by step solution to this problem since i am new to crystal reports.
for alternatives i have currency symbol in an enum, db, culture, any short way of solving this problem is appreciated as in where i wont have to pass values to crystal reports individually, passing them through either formula might be considerable but i wish to set the fields to currency type and let the framework handle the rest for me.
I have made a Parameter formula field to take the value and bring it on the Report by sending Value
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports CrystalDecisions.ReportSource
Imports TimexSageEvoReportsWriter.clsEvoRequired
Private Const crParameterCurrency As String = "CurrencyCode"
Dim CrystlRpt As New ReportDocument
Dim myParameterFields As ParameterFields
CrystlRpt.FileName = reportPath
myParameterFields = CrystlRpt.ParameterFields
myParameterFields.Item(0).CurrentValues.Clear()
Dim currentParameterValues As ParameterValues = New ParameterValues()
Dim thisParameterField As ParameterField = myParameterFields(crParameterCurrency)
If thisParameterField.PromptingType = DiscreteOrRangeKind.DiscreteValue Then
Dim myParameterDiscreteValue As ParameterDiscreteValue = New ParameterDiscreteValue()
myParameterDiscreteValue.Value = myArrayList(0)(0).ToString()
currentParameterValues.Add(myParameterDiscreteValue)
End If
crViewer.ViewerCore.ReportSource = CrystlRpt
Only I have to get a formula to make this appear in the Currency Symbol of the Fields, for now I have placed the Currency Code near the Amount Field to appear like a formatted amount , and made the symbol to be blank in Crystal manually.
Related
I got a stored procedure dbo.getTree with one parameter "#order". Since it is T-SQL the "#" at the beginning of the parameter is necessary.
When I add that stored procedure to Crystal Reports it will generat a parameter #order.
Now the problem is that the program calling the report, requires me to name the parameter, for fetching the data, "order" without the "#".
So now i got two parameters "order" and "#order".
How can i pass the value of "order" to "#order" so the right stored procedure is called.
First: You can pass your parameter using code behind like this:
ParameterField paramField = new ParameterField();
ParameterDiscreteValue paramDiscreteValue = new ParameterDiscreteValue();
paramField.Name = "mo"; remember this is your parameter name at your crystal report
paramDiscreteValue.Value = "02";
paramField.CurrentValues.Add(paramDiscreteValue);
paramFields.Add(paramField);
Second: You have to put your parameter into your query at crystal report command i suggest, if you want a dynamic data result on it, for example it has a parameter of startdate and enddate.
Using VB.NET 2010 and SQL Server 2008 R2.
I have inherited an application with a RDLC report. I have not used those before. The report was created and works fine but the originator left out a set of data, a subreport for the "parent" record reported on.
I have tried to add a subreport, point the input parameters of the main to the sub(they use same information). Have the sub use a Dataset that points to a Stored procedure and display the results.
Any attempt to execute (and display) sub report data fails with the message
Data retrieval failed for subreport....located at....Please check the log files for more information.
Off what/where are the log files located?
I can pass in params and as long as I add a dataset w/a stored procedure, I can see the params if I put on report. If I add the stored procedure ...Nothing. I tried a fix found on internet to create a Copy of the XSD's stored procedure call... but that didn't work either.
Main report works fine without Sub.
Thoughts?
What am I missing?
Shouldn't I be able to add a subreport, link up the parameters and have subreport display related information?
Here is my code to call main report:
Dim adapter As New SqlClient.SqlDataAdapter
Dim table As New DataTable
Try
Cursor.Current = Cursors.WaitCursor
ReportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Local
ReportViewer1.LocalReport.ReportPath = Application.StartupPath & "\IndividualInterviewerDataReport.rdlc"
Dim ReportParameters(5) As Microsoft.Reporting.WinForms.ReportParameter
ReportParameters(0) = New Microsoft.Reporting.WinForms.ReportParameter("SurveyName", frmMain.SurveyName)
ReportParameters(1) = New Microsoft.Reporting.WinForms.ReportParameter("Interviewer", InterviewerId)
ReportParameters(2) = New Microsoft.Reporting.WinForms.ReportParameter("Panel", PanelMonth)
'
'
ReportParameters(3) = New Microsoft.Reporting.WinForms.ReportParameter("- Version: " + ProductVersion)
ReportParameters(4) = New Microsoft.Reporting.WinForms.ReportParameter("PanelYear", PanelYear)
ReportParameters(5) = New Microsoft.Reporting.WinForms.ReportParameter("SurveyNbr", frmMain.SurveyNum)
ReportViewer1.LocalReport.SetParameters(ReportParameters)
ReportViewer1.ShowPrintButton = True
ReportViewer1.ZoomPercent = 100
Me.spInterviewerDataByPanelTableAdapter.Connection.ConnectionString = My.Settings.DBConnection
Me.spInterviewerDataByPanelTableAdapter.Fill(Me.CodingControlDataSet.spInterviewerDataByPanel, frmMain.SurveyNum, PanelYear, PanelMonth, InterviewerId)
Me.ReportViewer1.RefreshReport()
If I'm remembering correctly, you'll need to handle the SubreportProcessing event of the LocalReport object, and set the subreport data there. You do this by setting a property of the EventArgs parameter for the event handler.
Here's some code (adapted from Microsoft documentation):
'In your report setup code'
AddHandler Me.ReportViewer1.LocalReport.SubreportProcessing, _
AddressOf DemoSubreportProcessingEventHandler
'Event hander
Public Sub DemoSubreportProcessingEventHandler(ByVal sender As Object, _
ByVal e As SubreportProcessingEventArgs)
e.DataSources.Add(New ReportDataSource("DatasetNameInReport", MyDataTable ))
End Sub
I'm developing an SSIS 2012 package which uses a Script task to load and render an SSRS 2012 report from an SSRS server via a web service using SOAP. My problem lies in the code that sets the parameter values. When the code below runs, I get the following SOAP error message when it tries to execute the rs.SetExecutionParameters method:
Microsoft.ReportingServices.Diagnostics.Utilities.UnknownReportParameterException: An attempt was made to set a report parameter 'prmDomainID' that is not defined in this report.
Yet if I open the report in Design mode, the parameter is clearly there. And checking the execInfo variable at run-time, also shows the parameter is there. I've tried deleting the report on the server and redeploying it but that didn't work. I've tried changing the parameter name to include the leading "#" symbol but that didn't work either. I've made sure the parameter data type (integer) matches the type of value I'm passing in. I've been googling for hours and nothing seems to make it recognize the parameters I'm passing in. (Note the prmDomainID parameter is set to Visible. Not sure if that matters.)
What am I missing here?
Dim rs As New ReportExecutionService
Dim format As String = "HTML4.0"
Dim mimeType As String = Nothing
Dim historyID As String = Nothing
Dim deviceInfo As String = Nothing
Dim extension As String = Nothing
Dim encoding As String = Nothing
Dim warnings() As Warning = Nothing
Dim streamIDs() As String = Nothing
Dim results() As Byte
Dim execInfo As New ExecutionInfo
Dim parameters(1) As ParameterValue
parameters(0) = New ParameterValue()
parameters(0).Name = "prmDomainID"
parameters(0).Value = "15"
With rs
.Credentials = System.Net.CredentialCache.DefaultCredentials
execInfo = .LoadReport(ReportPath, historyID)
.SetExecutionParameters(parameters, "en-us")
results = .Render(format, deviceInfo, extension, mimeType, encoding, warnings, streamIDs)
End With
Return System.Text.Encoding.Default.GetString(results)
Did you get this to work? I have looked and looked at this - and the only things I see are that I don't see where your ReportPath is set - but I assume it is because you got data in execInfo... so the only other thing I see is that you don't have the ExecutionHeaderValue set...
so add this code and give it a try...
Dim execHeader as New ExecutionHeader()
rs.ExecutionHeaderValue = execHeader
make sure you put it before execInfo = .LoadReport(ReportPath, historyID)
I tried to convert my c# code to VB - so you may want to verify syntax!
I have a SSRS "statement" type report that has general layout of text boxes and tables. For the main text box I want to let the user supply the value as a parameter so the text can be customized, i.e.
Parameters!MainText.Value = "Dear Mr.Doe, Here is your statement."
then I can set the text box value to be the value of the parameter:
=Parameters!MainText.Value
However, I need to be able to allow the incoming parameter value to include a dataset field, like so:
Parameters!MainText.Value = "Dear Mr.Doe, Here is your [Fields!RunDate.Value] statement"
so that my report output would look like:
"Dear Mr.Doe, Here is your November statement."
I know that you can define it to do this in the text box by supplying the static text and the field request, but I need SSRS to recognize that inside the parameter string there is a field request that needs to be escaped and bound.
Does anyone have any ideas for this? I am using SSRS 2008R2
Have you tried concatenating?
Parameters!MainText.Value = "Dear Mr.Doe, Here is your" & [Fields!RunDate.Value] & "statement"
There are a few dramatically different approaches. To know which is best for you will require more information:
Embedded code in the report. Probably the quickest to
implement would be embedded code in the report that returned the
parameter, but called String.Replace() appropriately to substitute
in dynamic values. You'll need to establish some code for the user for which strings will be replaced. Embedded code will get you access to many objects in the report. For example:
Public Function TestGlobals(ByVal s As String) As String
Return Report.Globals.ExecutionTime.ToString
End Function
will return the execution time. Other methods of accessing parameters for the report are shown here.
1.5 If this function is getting very large, look at using a custom assembly. Then you can have a better authoring experience with Visual Studio
Modify the XML. Depending on where you use
this, you could directly modify the .rdl/.rdlc XML.
Consider other tools, such as ReportBuilder. IF you need to give the user
more flexibility over report authoring, there are many tools built
specifically for this purpose, such as SSRS's Report Builder.
Here's another approach: Display the parameter string with the dataset value already filled in.
To do so: create a parameter named RunDate for example and set Default value to "get values from a query" and select the first dataset and value field (RunDate). Now the parameter will hold the RunDate field and you can use it elsewhere. Make this parameter hidden or internal and set the correct data type. e.g. Date/Time so you can format its value later.
Now create the second parameter which will hold the default text you want:
Parameters!MainText.Value = "Dear Mr.Doe, Here is your [Parameters!RunDate.Value] statement"
Not sure if this syntax works but you get the idea. You can also do formatting here e.g. only the month of a Datetime:
="Dear Mr.Doe, Here is your " & Format(Parameters!RunDate.Value, "MMMM") & " statement"
This approach uses only built-in methods and avoids the need for a parser so the user doesn't have to learn the syntax for it.
There is of course one drawback: the user has complete control over the parameter contents and can supply a value that doesn't match the report content - but that is also the case with the String Replace method.
And just for the sake of completeness there's also the simplistic option: append multiple parameters: create 2 parameters named MainTextBeforeRunDate and MainTextAfterRunDate.
The Textbox value expression becomes:
=Parameters!MainTextBeforeRunDate.Value & Fields!RunDate.Value & Parameters!MainTextAfterRunDate.Value.
This should explain itself. The simplest solution is often the best, but in this case I have my doubts. At least this makes sure your RunDate ends up in the final report text.
The application I work on is using a Crystal Reports to present reports to the user. I am using Visual 2010, but the report was created by a previous employee some years back using Visual2005.
The basic setup is that the client application make a request to the server that uses a xsd that define the data-set it sends back. Generally this work like expected, but I am having some problems with evaluating booleans.
A recent task consider of adding the dataset with a field name TrueWeekday that control if certain numbers should be printed out or not depending on if a date is a regular weekday or have some special local meaning that might affect the sampled data. The data is always used in some formulas so I can not exclude it from the dataset.
My first attempt involved defining the new field as a boolean and in the formula for the report I wrote
if {Header.TrueWeekday} then
CStr({Detail.Flow})
else
""
This had the result that no matter if the value in TrueWeekday was false or true the flow was presented. I debuged the server to verify that the variable indeed got the expected value so the problem happened in the Crystal Reports or in the transfer of data to Crystal Reports.
To solve this particular problem within the timeconstraints of the task I changed the field to the type string and wrote
if {Header.TrueWeekday} = "false" then
CStr({Detail.Flow})
else
""
This worked like a charm.
My problem here is not urgent since I have a working solution, but I am worried that this problem might create more subtle dataintrigity problems.
What might be the cause of this and how do I solve it?
Header.TrueWeekday is probably being passed as a string so that when you do if {Header.TrueWeekday} its testing a string as a boolean in which case if the string contains anything it evaluates to true and thus causes your problem
Work in a different project made me realize that .Net is probably serializing the boolean as the text string true/false. If then Crystal Reports does sloppy import and only check
input != 0
you will get the result that both true and false map to true after the transfer.