Evitar la ventana Pedir valores de parametros en Crystal Report y VS2010

2,443 views
Skip to first unread message

Luis Alberto Turbi Mella

unread,
Mar 21, 2014, 10:29:01 AM3/21/14
to csharp...@googlegroups.com
Saludos:

Amigos tengo un reporte en CR, trabajo en VS2010. Le paso tres paramertos, pero siempre me visualiza la ventana para introducir los valores

En foxpro evitaba esta ventana con la propiedad   oReporte.EnableParameterPrompting= .F. &&No Pregunta por los Parametros

pero esta no existe en esta versión. Cual puedo utilizar??

Paso los parametros asi:

          oReporte.SetParameterValue("dFechaInicial", dates.TTOD(dFechaInicial));
          oReporte.SetParameterValue("dFechaFinal", dates.TTOD(dFechaFinal));
          oReporte.SetParameterValue("cUsuario", "TURBIL");

Gracias por cualquier ayuda

Domingo Cuevas

unread,
Mar 21, 2014, 11:39:01 AM3/21/14
to csharp...@googlegroups.com

Yo, le envio los parametros poniendo @
 oReporte.SetParameterValue("@dFechaInicial", dates.TTOD(dFechaInicial));
y en el reporte tiene que tener el nombre exactamente igual.

Saludos,


--
Has recibido este mensaje porque estás suscrito al grupo "C#.NET Latinoamérica" de Grupos de Google.
Visita este grupo en http://groups.google.com/group/csharplatino.


Analyzer

unread,
Mar 21, 2014, 11:51:12 AM3/21/14
to csharp...@googlegroups.com
Que raro.. Nunca nos pasó eso de los parametros con CR y C#.

Por acá dejamos como armar reportes con Crystal Reports:

Curso de C# Parte 4 Crystal Reports y Crear Instalador

https://groups.google.com/forum/?hl=es#!topic/csharplatino/b1vD27aJ23g

Si he visto que pide parametros, pero eso lo vi con una aplicación de vb6 y no investigue como quitarlo..


Saludos!

Luis Alberto Turbi Mella

unread,
Mar 21, 2014, 1:00:27 PM3/21/14
to csharp...@googlegroups.com
Gracias,

Bueno, le puse el caracter @ , y ahora me despleiga el error: "El indice no es valido", jejeje. sigo buscando y les comento.
Gracias por cualquier ayuda

Luis Alberto Turbi Mella

unread,
Mar 21, 2014, 3:53:56 PM3/21/14
to csharp...@googlegroups.com
Modifique el codigo, por este, pero me marca error "Puntero no valido" al cargar el reporte

 // Coleccion
               ParameterFields  oParametrosCR = new ParameterFields();
               ParameterValues oParametrosValuesCR = new ParameterValues();

                // parametros
               ParameterField   oFechaInicial = new ParameterField();
               ParameterField     oFechaFinal = new ParameterField();
               oFechaInicial.ParameterValueType =  ParameterValueKind.DateParameter;
               oFechaFinal.ParameterValueType =  ParameterValueKind.DateParameter;
                
                // Valores paralos prametros
                ParameterDiscreteValue oFechaInicialDValue = new ParameterDiscreteValue();
                ParameterDiscreteValue oFechaFinalDValue = new ParameterDiscreteValue();

                oFechaInicialDValue.Value  = dFechaInicial;
                oFechaFinalDValue.Value = dFechaFinal;

                oFechaInicial.CurrentValues.Add(oFechaInicialDValue);
               oFechaFinal.CurrentValues.Add(oFechaFinalDValue);

                oParametrosCR.Add(oFechaInicial);
                oParametrosCR.Add(oFechaFinal);

                oParametrosCR[0].Name = "dFechaInicial" ;
                oParametrosCR[0].Name = "dFechaFinal";

               // oReporte.DataDefinition.ParameterFields("@dFechaInicial").ApplyCurrentValues(oParametrosCR[0]);
               // oReporte.DataDefinition.ParameterFields("@dFechaFinal").ApplyCurrentValues(oParametrosCR[1]);

                  GsiConta.rptEntradasDiarios oReporte = new rptEntradasDiarios();                        
                  frmPrinter ofrmPrinter = new frmPrinter(dtDatos, oReporte, cTitulo);
                  ofrmPrinter.CrystalReportViewer1.ParameterFieldInfo = oParametrosCR;
                 ofrmPrinter.ShowDialog(); 

Gracias por cualquier ayuda

Domingo Cuevas

unread,
Mar 22, 2014, 8:13:40 AM3/22/14
to csharp...@googlegroups.com

oParametrosCR[0].Name = "dFechaInicial" ;

oParametrosCR[0].Name = "dFechaFinal";   El error es por esto [0]

 

 // oReporte.DataDefinition.ParameterFields("@dFechaInicial").ApplyCurrentValues(oParametrosCR[0]);

 // oReporte.DataDefinition.ParameterFields("@dFechaFinal").ApplyCurrentValues(oParametrosCR[1]);  Aquí tienes [1]

 

Me imagino que cuando lo corriste no estaba con comentario (//).

 

Saludos,

--

Luis Alberto Turbi Mella

unread,
Mar 23, 2014, 9:33:37 AM3/23/14
to csharp...@googlegroups.com

Gracias DCuevas. 

El código quedo asi:

                // Parametros de Fecha para visualizar en el Reporte CR
                DateTime dFechaInicial = this.txtfechaentrada.Value;
                DateTime dFechaFinal = this.txtfechaFinal.Value;
                String cUsuario = "TURBIL";

               // Coleccion
               ParameterFields  oParametrosCR = new ParameterFields();
               ParameterValues oParametrosValuesCR = new ParameterValues();

                // parametros
               ParameterField   oFechaInicial = new ParameterField();
               ParameterField     oFechaFinal = new ParameterField();
               ParameterField        oUsuario = new ParameterField();
               oFechaInicial.ParameterValueType =  ParameterValueKind.DateParameter;
               oFechaFinal.ParameterValueType   =  ParameterValueKind.DateParameter;
               oUsuario.ParameterValueType      = ParameterValueKind.StringParameter;

                // Valores paralos prametros
                ParameterDiscreteValue oFechaInicialDValue = new ParameterDiscreteValue();
                ParameterDiscreteValue oFechaFinalDValue = new ParameterDiscreteValue();
                ParameterDiscreteValue oUsuarioDValue = new ParameterDiscreteValue();
                oFechaInicialDValue.Value  = dFechaInicial;
                oFechaFinalDValue.Value = dFechaFinal;
                oUsuarioDValue.Value =    cUsuario;

                // Agrego los valores a los parametros
                oFechaInicial.CurrentValues.Add(oFechaInicialDValue);
                oFechaFinal.CurrentValues.Add(oFechaFinalDValue);
                oUsuario.CurrentValues.Add(oUsuarioDValue);

                // Agrego los parametros a la coleccion
                oParametrosCR.Clear();
                oParametrosCR.Add(oFechaInicial);
                oParametrosCR.Add(oFechaFinal);
                oParametrosCR.Add(oUsuario);

                // Nombre del Parametro en CR
                oParametrosCR[0].Name = "dFechaInicial" ;
                oParametrosCR[1].Name = "dFechaFinal";
                oParametrosCR[2].Name = "cUsuario";

Glenan BMK

unread,
Sep 4, 2015, 6:41:10 PM9/4/15
to C#.NET Latinoamérica
a mi me aparecio "puntero no valido" cuando estaba llenando los parametros de forma desordenada, tienes que hacerlo tal y como esta en el diseñador del crystal, en el mismo orden.
Reply all
Reply to author
Forward
0 new messages