none
Local Reports in VS 2008 - Setting Parameters RRS feed

  • Question

  • I have developed a number of reports in VS 2005 that I am now trying to migrate to VS 2008. I can bring up a report that has no parameters, but can't seem to set parameters for those that have them. The current incarnation of the code (and I've tried MANY variations on this code) is:

    private void button1_Click(object sender, EventArgs e)
    {
        
    string strReportPath = "ProjectName.MyReport.rdlc";
        
    ReportParameter param = new ReportParameter();
        param.Name =
    "Field Name";
        param.Values.Add(
    "Value");

        reportViewer1.ProcessingMode = ProcessingMode.Local;
        reportViewer1.LocalReport.ReportPath = strReportPath;

        //Get error message on the following line of code
        reportViewer1.LocalReport.SetParameters (
    new ReportParameter[] {param});

        reportViewer1.ShowParameterPrompts =
    false;
        reportViewer1.ShowPromptAreaButton =
    false;
        reportViewer1.RefreshReport();
    }

    The message indicates that the report definition hasn't been specified, but I only get that error message when I try to run a report with one or more parameters, and the error occurs at the point where the report parameters are set.

    Thanks.
    Wednesday, July 16, 2008 3:59 PM

All replies

  • It's not clear from the information in your post, but I'm wondering if the problem is not that you haven't pointed the viewer at a report definition, but rather that it can't find the definition at the location you specified.  If you post the exact error message, I should be able to tell.

    The report path you specified is a valid file name, but I wonder if you actually intended it as an embedded resource.  If that is the case, you should be using the ReportEmbeddedResource property.  But since this is working for reports without parameters, that seems less likely.

    I don't see anything wrong with the order of the statements in your code.  The exact error message should help narrow down the issue.

    Thursday, July 17, 2008 1:48 AM
    Moderator
  • Hi, Brian. Thanks for responding to my request so quickly. The error message I'm getting is: "The 'CustomerGroup' parameter is missing a value." If I step through the code, I get the following message:

    Microsoft.Reporting.WinForms.LocalProcessingException was unhandled
      Message="An error occurred during local report processing."
      Source="Microsoft.ReportViewer.WinForms"
      StackTrace:
           at Microsoft.Reporting.WinForms.LocalReport.SetParameters(IEnumerable`1 parameters)
           at Test.Reports.button1_Click(Object sender, EventArgs e) in C:\Returns\Test\Test\Reports.cs:line 42
           at System.Windows.Forms.Control.OnClick(EventArgs e)
           at System.Windows.Forms.Button.OnClick(EventArgs e)
           at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
           at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
           at System.Windows.Forms.Control.WndProc(Message& m)
           at System.Windows.Forms.ButtonBase.WndProc(Message& m)
           at System.Windows.Forms.Button.WndProc(Message& m)
           at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
           at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
           at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
           at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
           at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
           at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
           at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
           at System.Windows.Forms.Application.Run(Form mainForm)
           at Test.Program.Main() in C:\Returns\Test\Test\Program.cs:line 18
           at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
           at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
           at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
           at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Threading.ThreadHelper.ThreadStart()
      InnerException: System.ApplicationException
           Message="The report definition for report 'C:\\Returns\\Test\\Test\\bin\\Debug\\Test.OpenRAsByCustomerGroup.rdlc' has not been specified"
           Source="Microsoft.ReportViewer.Common"
           StackTrace:
                at Microsoft.Reporting.StandalonePreviewStore.GetCompiledReport(CatalogItemContext context, Boolean rebuild, ReportSnapshotBase& snapshot)
                at Microsoft.Reporting.LocalService.GetReportParameters(CatalogItemContext reportContext, NameValueCollection userSpecifiedValues, ParameterInfoCollection baseLineParameters, DatasourceCredentialsCollection credentials, ReportRuntimeSetup reportRuntimeSetup)
                at Microsoft.Reporting.WinForms.LocalReport.SetParameters(IEnumerable`1 parameters)
           InnerException: System.IO.FileNotFoundException
                Message="Could not find file 'C:\\Returns\\Test\\Test\\bin\\Debug\\Test.OpenRAsByCustomerGroup.rdlc'."
                Source="mscorlib"
                FileName="C:\\Returns\\Test\\Test\\bin\\Debug\\Test.OpenRAsByCustomerGroup.rdlc"
                StackTrace:
                     at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
                     at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
                     at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
                     at System.IO.File.OpenRead(String path)
                     at Microsoft.Reporting.StandalonePreviewStore.GetReportDefinition(String path, Boolean isFile)
                     at Microsoft.Reporting.StandalonePreviewStore.GetCompiledReport(CatalogItemContext context, Boolean rebuild, ReportSnapshotBase& snapshot)
                InnerException:

    Hope you can help. I really need to be able to get these reports migrated to VS 2008 as local reports.

    Thanks,
    Carolyn

    Tuesday, July 22, 2008 6:53 PM