Reputation: 1499
I've got this block of code:
ErrorLogging.WriteLog(string.Format("Username = {0}, userkey = {1}, userID = {2}", CurrentUser.Username, CurrentUser.UserKey, CurrentUser.Username + CurrentUser.UserKey.ToString()));
ssrsRV.ProcessingMode = ProcessingMode.Remote;
ssrsRV.ServerReport.ReportServerUrl = new Uri(SystemConfig.SSRSServerURI);
ssrsRV.ServerReport.ReportPath = report.REPORT ?? string.Empty;
ssrsRV.ServerReport.SetParameters(new ReportParameter("UserID", CurrentUser.Username + CurrentUser.UserKey.ToString()));
The first line just proves to myself that I've got valid information in the those variables. The userID ends up being something like "jsmith162e4aa1-d8d3-427b-bd3d-71b7f0307856"
ssrsRV is an Microsoft.Reporting.WebForms.ReportViewer
object.
When I try and run this code I get this error message:
The path of the item '/MyFolder/MyExampleReport.rdl~!@~!@' is not valid. The full path must be less than 260 characters long; other restrictions apply. If the report server is in native mode, the path must start with slash. (rsInvalidItemPath)
The exception is thrown by the SetParameters
method, so I'm sure that's the problem, but I haven't tested not passing parameters at all.
Any clue what I'm doing wrong? What I should try next?
Upvotes: 2
Views: 4232
Reputation: 1499
I'm dumb.
The code was perfect, the application was adding the "~!@~!@" to the report path in the database without displaying it to the user. If I write a SQL statement to remove those characters from the report path in the database, it works perfectly.
Thanks,
Upvotes: 1
Reputation: 4972
You'll need to declare the report parameter first:
ReportParameter[] RptParameters = new ReportParameter[1];
Then assign the parameter:
RptParameters[0] = new ReportParameter("UserID", CurrentUser.Username + CurrentUser.UserKey.ToString());
Then set the parameter:
ssrsRV.ServerReport.SetParameters(RptParameters);
See how this goes.
Upvotes: 0