Crystal Report - Como instanciar un Criystal Report en aspx.net

 
Vista:

Como instanciar un Criystal Report en aspx.net

Publicado por felipe (4 intervenciones) el 13/03/2009 05:20:41
Saludos, de antemano agradesco a quien pueda ayudarme y todos los que traten de hacerlo.
He estado tratando de crear un reporte con crystal report para una aplicacion web basandome en otros reportes que he hecho en aplicaciones windows y un articulo encontrado en internet bastante interesante.
http://www.elguille.info/colabora/puntoNET/ericeec_InformeConCrystalReportDataset.htm
en el momento en q voy a instanciar mi reporte ya creado para asignar el dataset tipado .Net no me reconoce el reporte.
miReporte objReporte = new miReporte();
no logro q reconosca "miReporte". TEngo instalado el framework para CrystalReports.
Espero pueda ayudarme.

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using CrystalDecisions.Shared;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Web;
using CrystalDecisions.ReportSource;

public partial class wfReporteFacturasPendientes : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection ObjConexion = new SqlConnection(ConfigurationManager.ConnectionStrings["MibasededatosConnectionString"].ConnectionString);
ObjConexion.Open();
SqlCommand objComando = new SqlCommand();
objComando.CommandType = CommandType.StoredProcedure;
objComando.CommandText = "rConsultarCliente";
objComando.Connection = ObjConexion;
objComando.ExecuteNonQuery();

SqlCommand objComando1 = new SqlCommand();
objComando1.CommandType = CommandType.StoredProcedure;
objComando1.CommandText = "rConsultarFacturas";
objComando1.Connection = ObjConexion;
objComando1.ExecuteNonQuery();

dsFacturasPendientes dsFP = new dsFacturasPendientes();
SqlDataAdapter da = new SqlDataAdapter(objComando);
SqlDataAdapter da1 = new SqlDataAdapter(objComando1);
da.Fill(dsFP.CLIENTES);
da1.Fill(dsFP.FACTURAS);
miReporte objReporte = new miReporte(); --->> //No logro q reconosca "miReporte"
objReporte .SetDataSource(dsFP);
crystalReportViewer1.ReportSource = objReporte;

}
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:Como instanciar un Criystal Report en aspx.net

Publicado por felipe (4 intervenciones) el 13/03/2009 06:16:47
Bueno, yo mismo he respondido a mi pregunta con el siguiente codigo aca se los dejo por si a alguien le sirve (incluido yo), igual no sé si es una buena practica pero funciona.

ReportDocument crReport = new ReportDocument();
string reportName = "crFacturasPendientes.rpt";
string pathReport = Server.MapPath(reportName);
crReport.Load(pathReport);
crReport.SetDataSource(dsFP); //@dsFP, este es mi dataset tipado
crvFacturasPendientes.ReportSource = crReport; //@crvFacturasPendientes, este es mi crystal report viewer

y aqui todo el codigo del evento load del webform

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using CrystalDecisions.Shared;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Web;
using CrystalDecisions.ReportSource;

public partial class wfReporteFacturasPendientes : System.Web.UI.Page
{
ReportDocument crReport = new ReportDocument();
protected void Page_Load(object sender, EventArgs e)
{

SqlConnection ObjConexion = new SqlConnection(ConfigurationManager.ConnectionStrings["DBUNIFRUTASConnectionString"].ConnectionString);
ObjConexion.Open();
SqlCommand objComando = new SqlCommand();
objComando.CommandType = CommandType.StoredProcedure;
objComando.CommandText = "rConsultarCliente";
objComando.Connection = ObjConexion;
objComando.ExecuteNonQuery();

SqlCommand objComando1 = new SqlCommand();
objComando1.CommandType = CommandType.StoredProcedure;
objComando1.CommandText = "rConsultarFacturas";
objComando1.Connection = ObjConexion;
objComando1.ExecuteNonQuery();

dsFacturasPendientes dsFP = new dsFacturasPendientes();
SqlDataAdapter da = new SqlDataAdapter(objComando);
SqlDataAdapter da1 = new SqlDataAdapter(objComando1);
da.Fill(dsFP.CLIENTES);
da1.Fill(dsFP.FACTURAS);
string reportName = "crFacturasPendientes.rpt";
string pathReport = Server.MapPath(reportName);
crReport.Load(pathReport);
crReport.SetDataSource(dsFP);
crvFacturasPendientes.ReportSource = crReport;


}
}
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar