我花了很长时间才弄清楚这一点。我以正确的方式传递参数(按照网络上的一些教程)。.rdlc 也有我的参数的正确符号(表达式)(=Parameters!myparam1.Value)使用报告窗口贴花。
计划是在我单击一个按钮后加载报告。但是当它试图设置参数时,错误就发生了。这是代码:
private void button4_Click(object sender, EventArgs e)
{
ReportViewer reportViewer1 = new ReportViewer();
reportViewer1.LocalReport.ReportPath = "AddressLabelReport.rdlc";
reportViewer1.ProcessingMode = ProcessingMode.Local;
reportViewer1.LocalReport.SetParameters(new ReportParameter[] { new ReportParameter ("myparam1", "my value1", false), new ReportParameter("myparam2", "my value2", false) });
reportViewer1.RefreshReport();
}
这是 StackTrace :
Microsoft.Reporting.WinForms.LocalProcessingException was unhandled
Message="An error occurred during local report processing."
Source="Microsoft.ReportViewer.WinForms"
StackTrace:
at Microsoft.Reporting.WinForms.LocalReport.CompileReport()
at Microsoft.Reporting.WinForms.LocalReport.SetParameters(IEnumerable`1 parameters)
at TextBookLabelForm.Form1.button4_Click(Object sender, EventArgs e) in C:\Projects\TextBookLabelForm\TextBookLabelForm\Form1.cs:line 204
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 TextBookLabelForm.Program.Main() in C:\Projects\TextBookLabelForm\TextBookLabelForm\Program.cs:line 17
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()
任何帮助都会得到帮助。谢谢你。