using a connection string in web.config for crystal report

Posted by zombiegx on Stack Overflow See other posts from Stack Overflow or by zombiegx
Published on 2010-05-06T22:02:07Z Indexed on 2010/05/06 22:08 UTC
Read the original article Hit count: 257

Filed under:
|

I`m having problems between two servers, wich use differente odbc dsn.

My apps work great but crystal reports uses the original odbc connection, how can I fix this?

I'm thinking of using the same connection string in the web.config, but I don't know how.

found this but is too confusing for me

this is an example of my code, its a aspx file that loads as a pdf

        protected void Page_Load(object sender, EventArgs e)
    {
        try
        {

            var par = Request.QueryString;
            int pidmun = 0;
            if (!string.IsNullOrEmpty(Request["id"]))
            {
                pidmun = int.Parse(Request["id"]);
            }
            string pFechaIni = Request["fi"];
            string pFechaFin = Request["ff"];
            string pTipo = Request["t"];
            string pNombreMunicipio = Request["nm"];
            var pos = Request.Form;
            if (string.IsNullOrEmpty(pFechaIni))
            {
                pFechaIni = "01/01/2010";
            }
            if (string.IsNullOrEmpty(pFechaFin))
            {
                pFechaFin = "01/01/2010";
            }
            if (string.IsNullOrEmpty(pTipo))
            {
                pTipo = "FOLIO";
            }
            if (string.IsNullOrEmpty(pNombreMunicipio))
            {
                pNombreMunicipio = "NombreMunicipio";
            }

            ReporteIngresos report = new ReporteIngresos();

            TextObject nom;
            TextObject periodo;
            nom = (TextObject)report.ReportDefinition.ReportObjects["TxtNombreMunicipio"];
            periodo = (TextObject)report.ReportDefinition.ReportObjects["TxtPeriodo"];
            nom.Text = "Ingresos Municipio de " + pNombreMunicipio;
            periodo.Text = "Periodo del " + pFechaIni + " al " + pFechaFin;

            report.SetParameterValue("pidMun", pidmun);
            report.SetParameterValue("pFechaIni", pFechaIni);
            report.SetParameterValue("pFechaFin", pFechaFin);
            report.SetParameterValue("pTipo", pTipo);

            MemoryStream oStream;
            oStream = (MemoryStream)report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
            Response.Clear();
            Response.Buffer = true;
            Response.AddHeader("CustomHeader", "ReporteIngresos");
            Response.CacheControl = "No-cache";
            Response.ContentType = "application/pdf";
            Response.BinaryWrite(oStream.ToArray());
            Response.End();
        }
        catch (Exception ex)
        {
            ExBi.log(ex);
            throw ex;
        }
    }

thanks.

© Stack Overflow or respective owner

Related posts about odbc

Related posts about ASP.NET