Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8372

Re: Error in File - Unable to connect: incorrect log on parameters.

$
0
0

I have installed the whole redist package. But i need to include all required dll and I am not able to find refrence of those dll.

 

I am getting this error when call the function to export as pdf.

 

My requirement is that I export data after filtering according to date. In some date range pdf is exporting successfully without any error.

But on some ranges of dates LogOn error occurs.

 

Following code I am using:

 

GenerateCrystalReport generatCR = new GenerateCrystalReport();

CrystalDecisions.CrystalReports.Engine.ReportDocument reportDocument =

new CrystalDecisions.CrystalReports.Engine.ReportDocument();

CrystalDecisions.ReportAppServer.ReportDefModel.Section headersection;

CrystalDecisions.ReportAppServer.ReportDefModel.Section columnsection;

CrystalDecisions.ReportAppServer.ReportDefModel.Section rowsection;

 

 

string name = ds_user.Tables[0].Rows[0]["name"].ToString();

string age_*** = age + "/" + ds_user.Tables[0].Rows[0]["***"].ToString();

string email_address = ds_user.Tables[0].Rows[0]["email"].ToString();

string contact = ds_user.Tables[0].Rows[0]["contactno"].ToString().Replace("+", "");

string printdate = DateTime.UtcNow.ToString("dd MMM yyyy");

string daterange =  Convert.ToDateTime(tb_from).ToString("dd MMM yyyy") + " To " + Convert.ToDateTime(tb_to).ToString("dd MMM yyyy");

 

 

reportDocument.Load(HttpContext.Current.Server.MapPath("~/bin/reports/List.rpt"));

 

 

ISCDReportClientDocument reportClientDoc = reportDocument.ReportClientDocument;

dataSetReportDetails.WriteXml(HttpContext.Current.Server.MapPath("~/bin/reports/MList.xml"), XmlWriteMode.WriteSchema);

CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo connectionInfo = generatCR.getConnectionInfo(HttpContext.Current.Server.MapPath

 

 

("~/bin/reports/MList.xml"));

                           

reportDocument.Subreports[0].SetDataSource(dataSetReportDetails.Tables[0]);

generatCR.SetParameters(reportDocument, name, age_***, email_address, contact, printdate, daterange);

downloadPDF(reportDocument, "Details_List" + daterange + ".pdf");

 

 

  //function to get connection info for created xml file from dataset

    public CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo getConnectionInfo(string xmlFilePath)

    {

        PropertyBag logonInfo = new PropertyBag();

        logonInfo.EnsureCapacity(1);

        logonInfo.Add("XML File Path", xmlFilePath);

 

 

        PropertyBag attributes = new PropertyBag();

        attributes.EnsureCapacity(5);

        attributes.Add("Database DLL", "crdb_adoplus.dll");

        attributes.Add("QE_DatabaseType", "ADO.NET (XML)");

        attributes.Add("QE_ServerDescription", "NewDataSet");

 

 

        attributes.Add("QE_SQLDB", true);

        attributes.Add("QE_LogonProperties", logonInfo);

        CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo connectionInfo = new CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo();

        connectionInfo.Kind = CrConnectionInfoKindEnum.crConnectionInfoKindCRQE;

        connectionInfo.Attributes = attributes;

        return connectionInfo;

    }

 

 

//set parameters value in report

public void SetParameters(ReportDocument reportDocument, string name, string age_***, string email_address, string contact, string printdate, string daterange)

    {

        reportDocument.SetParameterValue("pname", name);

        reportDocument.SetParameterValue("p_agesex", age_***);

        reportDocument.SetParameterValue("email_id", (email_address != "" && email_address != null) ? email_address : "NA");

        reportDocument.SetParameterValue("pcontact", (contact != "" && contact != null) ? contact : "NA");

        reportDocument.SetParameterValue("printdate", printdate);

        reportDocument.SetParameterValue("daterange", daterange);

        reportDocument.SetParameterValue("next_page_head", name );

        reportDocument.SetParameterValue("headerlogoPath", (HttpContext.Current.Server.MapPath("~/images/") + "Report-logo.png").ToString());

        reportDocument.SetParameterValue("single", true);

      reportDocument.SetParameterValue("today_date", Convert.ToDateTime(printdate).ToString("dd/MM/yyyy"));

                                reportDocument.SetParameterValue("today_date1", Convert.ToDateTime (printdate).ToString("dd/MM/yyyy"));

  reportDocument.SetParameterValue("picture_path", MyImgPath);

  reportDocument.SetParameterValue("picture_path1", MyImgPath);

    }

 

 

//Export to pdf

  public void downloadPDF(ReportDocument reportDocument, string filename, bool mobile)

    {

            MemoryStream oStream = (MemoryStream)reportDocument.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);

            reportDocument.Close();

            reportDocument.Dispose();

            HttpContext.Current.Response.ContentType = "application/pdf";

            HttpContext.Current.Response.AddHeader("Content-Length", oStream.Length.ToString());

            HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + filename);

            HttpContext.Current.Response.BinaryWrite(oStream.ToArray());

            HttpContext.Current.ApplicationInstance.CompleteRequest();

            HttpContext.Current.Response.End();

            reportDocument.Export();

    }

 

 

I find the exception As LogOn Failed in following line-

 

(MemoryStream)reportDocument.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);


Viewing all articles
Browse latest Browse all 8372

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>