Parametr w ReportViewer

0

Witam,
mam następujący problem nie mogę przekazać wartości do parametru @data_od znajdująca się w ReportViewer.
Obecnie robię to tak:

string data_rap = "Data probna";
          
ReportParameter nowy_data_od = new ReportParameter("data_od", data_rap);

reportViewer1.LocalReport.SetParameters(new ReportParameter[] {nowy_data_od});

Niestety to nie działa. Dodam jeszcze że wartości do raportu są dodawane z listy List<DaneRaportu> // DaneRaportu jest typem przechowującym właściwości poprane z bazy typu: artykuł, klient itp.

reportViewer1.LocalReport.DataSources.Clear(); //clear report
reportViewer1.LocalReport.ReportEmbeddedResource = "Raporting.Report_Promo.rdlc"; // bind reportviewer with .rdlc
Microsoft.Reporting.WinForms.ReportDataSource dataset = new Microsoft.Reporting.WinForms.ReportDataSource("DataSet1", lista); 
reportViewer1.LocalReport.DataSources.Add(dataset);
dataset.Value = lista; 

Pozdrawiam

0

Może rozwiń "Niestety to nie działa", i fajnie by było gdybyś używał znaczników kolorujących składnie.

0

Witam, podaje to co otrzymuje jako błąd, może ktoś coś z tego zrozumie, ja nie mam pojęcia o co w tym chodzi:

An error occurred during local report processing.

See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

         * Exception Text **************

Microsoft.Reporting.WinForms.LocalProcessingException: An error occurred during local report processing. ---> Microsoft.Reporting.DefinitionInvalidException: The definition of the report '' is invalid. ---> Microsoft.ReportingServices.ReportProcessing.ReportProcessingException: An unexpected error occurred in Report Processing. ---> System.UnauthorizedAccessException: Access to the path 'C:\Users\User\AppData\Local\Temp\expression_host_1f2d7bdeb7b24b8a9d99ff74d15a1b60.dll' is denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.File.InternalDelete(String path, Boolean checkHost)
at System.IO.File.Delete(String path)
at Microsoft.ReportingServices.RdlExpressions.ExprHostCompiler.InternalCompile(AppDomain compilationTempAppDomain, Boolean refusePermissions)
at Microsoft.ReportingServices.RdlExpressions.ExprHostCompiler.<>c__DisplayClass2.<Compile>b__0()
at Microsoft.ReportingServices.Diagnostics.RevertImpersonationContext.<>c__DisplayClass1.<Run>b__0(Object state)
at System.Security.SecurityContext.Run(SecurityContext securityContext, ContextCallback callback, Object state)
at Microsoft.ReportingServices.Diagnostics.RevertImpersonationContext.Run(ContextBody callback)
at Microsoft.ReportingServices.RdlExpressions.ExprHostCompiler.Compile(IExpressionHostAssemblyHolder expressionHostAssemblyHolder, AppDomain compilationTempAppDomain, Boolean refusePermissions, PublishingVersioning versioning)
at Microsoft.ReportingServices.ReportPublishing.ReportPublishing.Phase3(ParameterInfoCollection& parameters, Dictionary2& groupingExprCountAtScope) at Microsoft.ReportingServices.ReportPublishing.ReportPublishing.InternalCreateIntermediateFormat(Stream definitionStream, String& description, String& language, ParameterInfoCollection& parameters, DataSourceInfoCollection& dataSources, DataSetInfoCollection& sharedDataSetReferences, UserLocationFlags& userReferenceLocation, ArrayList& dataSetsName, Boolean& hasExternalImages, Boolean& hasHyperlinks, Byte[]& dataSetsHash) at Microsoft.ReportingServices.ReportPublishing.ReportPublishing.CreateIntermediateFormat(Byte[] definition, String& description, String& language, ParameterInfoCollection& parameters, DataSourceInfoCollection& dataSources, DataSetInfoCollection& sharedDataSetReferences, UserLocationFlags& userReferenceLocation, ArrayList& dataSetsName, Boolean& hasExternalImages, Boolean& hasHyperlinks, Byte[]& dataSetsHash) at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.CompileOdpReport(PublishingContext reportPublishingContext, IDataProtection dataProtection, PublishingErrorContext errorContext, String& reportDescription, String& reportLanguage, ParameterInfoCollection& parameters, DataSourceInfoCollection& dataSources, DataSetInfoCollection& sharedDataSetReferences, UserLocationFlags& userReferenceLocation, ArrayList& dataSetsName, Boolean& hasExternalImages, Boolean& hasHyperlinks, Byte[]& dataSetsHash) at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.CreateIntermediateFormat(PublishingContext reportPublishingContext, IDataProtection dataProtection) --- End of inner exception stack trace --- at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.CreateIntermediateFormat(PublishingContext reportPublishingContext, IDataProtection dataProtection) at Microsoft.Reporting.ReportCompiler.CompileReport(ICatalogItemContext context, Byte[] reportDefinition, Boolean generateExpressionHostWithRefusedPermissions, ControlSnapshot& snapshot) --- End of inner exception stack trace --- at Microsoft.Reporting.ReportCompiler.CompileReport(ICatalogItemContext context, Byte[] reportDefinition, Boolean generateExpressionHostWithRefusedPermissions, ControlSnapshot& snapshot) at Microsoft.Reporting.LocalService.GetCompiledReport(PreviewItemContext itemContext, Boolean rebuild, ControlSnapshot& snapshot) at Microsoft.Reporting.LocalService.CompileReport() at Microsoft.Reporting.LocalService.Microsoft.Reporting.ILocalProcessingHost.CompileReport() at Microsoft.Reporting.WinForms.LocalReport.EnsureExecutionSession() --- End of inner exception stack trace --- at Microsoft.Reporting.WinForms.LocalReport.EnsureExecutionSession() at Microsoft.Reporting.WinForms.LocalReport.SetParameters(IEnumerable1 parameters)
at Raporting.PDF_raport.PDF_raport_Load(Object sender, EventArgs e) in c:\Users\User\Documents\Visual Studio 2013\Projects\nowepolaczenie_na_ser\nowepolaczenie\PDF_raport.cs:line 50
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.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.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

         * Loaded Assemblies **************

mscorlib
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.18444 built by: FX451RTMGDR
CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll

Raporting
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/Users/User/Documents/Visual%20Studio%202013/Projects/nowepolaczenie_na_ser/nowepolaczenie/bin/Debug/Raporting.exe

System.Windows.Forms
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll

System.Drawing
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll

System
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll

System.Configuration
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll

System.Xml
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll

System.Core
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll

System.Data
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_32/System.Data/v4.0_4.0.0.0__b77a5c561934e089/System.Data.dll

System.Transactions
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_32/System.Transactions/v4.0_4.0.0.0__b77a5c561934e089/System.Transactions.dll

System.EnterpriseServices
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_32/System.EnterpriseServices/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll

Microsoft.ReportViewer.WinForms
Assembly Version: 11.0.0.0
Win32 Version: 11.0.3366.16 ((SQL11_SP1_RS_Dev12-RTM).130829-0516 )
CodeBase: file:///C:/windows/assembly/GAC_MSIL/Microsoft.ReportViewer.WinForms/11.0.0.0__89845dcd8080cc91/Microsoft.ReportViewer.WinForms.dll

Microsoft.ReportViewer.Common
Assembly Version: 11.0.0.0
Win32 Version: 11.0.3366.16 ((SQL11_SP1_RS_Dev12-RTM).130829-0516 )
CodeBase: file:///C:/windows/assembly/GAC_MSIL/Microsoft.ReportViewer.Common/11.0.0.0__89845dcd8080cc91/Microsoft.ReportViewer.Common.dll

Microsoft.SqlServer.Types
Assembly Version: 11.0.0.0
Win32 Version: 2011.0110.3366.016 ((SQL11_SP1_RS_Dev12-RTM).130829-0516 )
CodeBase: file:///C:/windows/assembly/GAC_MSIL/Microsoft.SqlServer.Types/11.0.0.0__89845dcd8080cc91/Microsoft.SqlServer.Types.dll

Microsoft.ReportViewer.ProcessingObjectModel
Assembly Version: 11.0.0.0
Win32 Version: 11.0.3366.16 ((SQL11_SP1_RS_Dev12-RTM).130829-0516 )
CodeBase: file:///C:/windows/assembly/GAC_MSIL/Microsoft.ReportViewer.ProcessingObjectModel/11.0.0.0__89845dcd8080cc91/Microsoft.ReportViewer.ProcessingObjectModel.dll

         * JIT Debugging **************

To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration> <system.windows.forms jitdebugging="true" /> </configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.

0

Może podpowiem o co mi chodzi wtedy może ktoś na coś wpadnie. Chce przekazać date do parametru w ReportViewer istnieje jako @data_od a robię to tak:
Najpierw łączę z bazą a następnie wysyłam do metody która zapisuje wszystko w klasie DaneRaportu w której znajdują się składowe Artykul, Kontrahent itd.
a następnie używam ReportParameter:

private void PDF_raport_Load(object sender, EventArgs e)
        {
polacz baza_win = new polacz(dane do polaczenia);
List<DaneRaportu> lista = polacz.pobierz_rap_dane(select ... from ... where);

reportViewer1.LocalReport.DataSources.Clear(); 
reportViewer1.LocalReport.ReportEmbeddedResource = "Raporting.Report_Promo.rdlc";
Microsoft.Reporting.WinForms.ReportDataSource dataset = new Microsoft.Reporting.WinForms.ReportDataSource("DataSet1", lista);
reportViewer1.LocalReport.DataSources.Add(dataset);
dataset.Value = lista;

string data_rap = "Dataprobna";
ReportParameter nowydataod = new ReportParameter("dataodview", data_rap);
reportViewer1.LocalReport.SetParameters(nowydataod);

reportViewer1.LocalReport.Refresh();
reportViewer1.RefreshReport();
}

1 użytkowników online, w tym zalogowanych: 0, gości: 1