Unrecognized SSRS parameters - soap

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!

Related

cyystal reports- setting currency symbol via globalisation (C# winforms)

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.

VB.NET 2010 RDLC Subreport "Data retrieval failed for the subreport"

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

Excel VBA: using R1C1 format, "Application defined or object defined error"

I am trying to create a formula that references other cells, but I keep getting this "Application defined or object defined error". I use R1C1 convention instead of Offset.
My Code:
Note: This code could be anywhere, I just need it to work. Also, I don't use the code like this. It is used in a reporting tool, but this is just similar code (to what I actually use) sufficient enough to show my problem
Cells(1, 1).Value = "5/1/2014 6:30"
soiDate = "$A$1"
Cells(10, 6).Value = "6/5/2014 14:12"
Cells(10, 10).Formula = "=(R[0]C[-4]-" & soiDate & ")*24" 'Error Occurs Here
UPDATE:
The following does not work either:
Cells(10, 10).FormulaR1C1 = "=(R[0]C[-4]-" & soiDate & ")*24"
Try this:
Cells(10, 10).FormulaR1C1 = _
"=(R[0]C[-4]-" & Range(soiDate).Address(, , xlR1C1) & ")*24"
It errors out since you kinda mixed up R1C1 reference to A1.
Just be consistent, you can use Range Object address property to convert reference. HTH.

Error with the Excel.Find function in VBScript

I am trying to create a VB script that searches through a column of dates and returns the address of the cell with todays date.
For some reason I keep getting an "Object required: 'FoundCell'" error.
Could someone have a look at my code and correct me?
I can read out the date using WScript.Echo, but once I use it in the find function it immediately gives me the error.
Set oExcel = CreateObject("Excel.Application")
Set wshShell = CreateObject("Wscript.Shell")
File_Path = "D:\Work\Personal Timemanagement\test.xlsx"
Set oData = oExcel.Workbooks.Open(File_Path)
WHAT_TO_FIND = Date()
WScript.Echo WHAT_TO_FIND
Set FoundCell = oData.Worksheets("tst2").Range("A1:A40").Find(WHAT_TO_FIND)
oExcel.Cells(4,4) = FoundCell.Address
oExcel.ActiveWorkbook.SaveAs "D:\Work\Personal Timemanagement\test2.xlsx"
oExcel.ActiveWorkbook.Close
oExcel.Application.Quit
WScript.Quit
Thanks for the help!
WHAT_TO_FIND1 returns value like #14/10/2014#.So replace the # with nothing using WHAT_TO_FIND1=Replace(WHAT_TO_FIND,"#","Nothing").
Once replaced the above code will work
I tried your script, works perfect for me.
For testing purposes I suggest you add the following line to the script
oExcel.Visible = True
Also make sure all the privies instances of Excel are closed so your script could get write access. (open task manager and end all Excel process - unless you have other excel files open)
Now make sure the Worksheet is spelled correct "tst2" also ensure that the range is correct "A1:A40"
Keep us posted.
Find() returns Nothing when the given value isn't found in the given range. Make sure that the Range A1:A40 on sheet tst2 in the workbook D:\Work\Personal Timemanagement\test.xlsx actually contains a cell with the current date, and that the cell is also formatted as a date. Find() won't return a match if for instance you're looking for a date 7/11/2013 and the range contains a cell (formatted as text) with the string 7/11/2013. Modify your statement like this for finding "text" cells:
Set FoundCell = oData.Worksheets("tst2").Range("A1:A40").Find(CStr(WHAT_TO_FIND))

When viewing a report inside an application, the parameter prompt redisplays when moving to the next page

I'm pretty much a novice with crystal reports. We have another team making our reports, and I'm integrating it with the application. The problem is with paging and user defined parameters. Essentially, the document.table. setdatasource points at our query result set (set in code). The report, upon opening, will then prompt the user for the parameter, which will further reduce the displayed result to the user as the prompt parameter is part of the record selection formula.
AND
{#Age} >= 20 and
{#Age} < 30 and
{Report;1.Sector} = {?NewSector})
This will return a table of more than one page in length. However, requesting the next page will result in the user being prompted for the Sector again, and once provided, will take the user back to page 1 of the results again.
If I take out the reference to the parameter, then obviously the paging works fine.
Is there away to just take the parameter once from the user, and then reuse this value in the subsequent paging requests?
Appreciate your help...
Stupid me. I had the report refreshing every postback.
EDit
A bit more elaboration:
I have the report being created in a RefreshReports procedure, which sets up the report as follows:
Dim objConnectionInfo As CrystalDecisions.Shared.ConnectionInfo
Dim crConnectionInfo As CrystalDecisions.Shared.ConnectionInfo
Dim myconnection As New SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings(ApplicationConstants.MyDB).ConnectionString)
Dim myConnBuilder As New SqlConnectionStringBuilder(myconnection.ConnectionString)
'// Log on credentials from web.config
objConnectionInfo = New CrystalDecisions.Shared.ConnectionInfo
objConnectionInfo.IntegratedSecurity = False
objConnectionInfo.ServerName = myconnection.DataSource
objConnectionInfo.UserID = myConnBuilder.UserID
objConnectionInfo.Password = myConnBuilder.Password
crConnectionInfo = objConnectionInfo
'// Get the report details needed
rep = Request.QueryString("Report")
crDoc.Load(Server.MapPath(rep))
crDoc.SetDatabaseLogon(myConnBuilder.UserID, myConnBuilder.Password)
Dim crDatabase As CrystalDecisions.CrystalReports.Engine.Database
Dim crTables As CrystalDecisions.CrystalReports.Engine.Tables
Dim aTable As CrystalDecisions.CrystalReports.Engine.Table
crDatabase = crDoc.Database
crTables = crDatabase.Tables
There is then a series of else ifs like the following:
ElseIf rep = "ExampleRep.rpt" Then
For Each aTable In crTables
If aTable.Name = "GetSectorRep;1" Then
Dim NewSector As String = ""
NewSector = Session("NewSector").ToString()
aTable.SetDataSource(DAL.GetSectorRepTable(NewSector))
End If
Next
In my Page_Init I grab the query strings I need and call RefreshReports. The problem I was having was that I was also requesting RefreshReports in a If Postback on page_load, which meant that every time the report posted back (eg. new page) it was requesting the parameter again, as the report was being created afresh.
So, silly me - quite an obvious mistake in the end!