0
votes

Please consider, I had my database in one server "RiboServer" and IIS in another server "IISServer". Due to some problem in RiboServer, I have restored my database to another server "NewServer".

Due to this change, my web application is working fine. But all the crystal reports are not opening.

It shows the error as ASP.stores_indent_ascx - Failed to open the connection. Details: [Database Vendor Code: 17 ] Failed to open the connection. IndentPOMRV {7BAD9D95-0A37-4041-8CBD-F4A3527C646E}.rpt Details: [Database Vendor Code: 17 ]

This is my code:

CrystalDecisions.CrystalReports.Engine.ReportDocument rpt =
                new CrystalDecisions.CrystalReports.Engine.ReportDocument();
try
{
    string conn = ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();
    string[] str = conn.Split(';');
    string server = str[0].Substring(str[0].IndexOf(" = ") + 3);
    string database = str[1].Substring(str[1].IndexOf(" = ") + 3);
    string userid = str[2].Substring(str[2].IndexOf(" = ") + 3);
    string password = str[3].Substring(str[3].IndexOf(" = ") + 3);

    rpt.Load(Server.MapPath("~/Purchase/Reports/SupplyPurchaseorder.rpt"));

    for (int i = 0; i < rpt.DataSourceConnections.Count; i++)
        rpt.DataSourceConnections[i].SetConnection(server, database, userid, password);
    rpt.SetParameterValue(0, POID);
    rpt.SetParameterValue(1, UserName);
    rpt.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, HttpContext.Current.Response, true, "SupplyPurchaseOrder");
}
catch (Exception ex)
{
    rpt.Dispose();
    BussinessLayer.RIBOException.Instance.HandleMe(this, ex);            
}

I can understand the above the error. But in my application I have more number of crystal reports, its very hard to change the database connection in each and every reports. So please suggests any solutions for this to solve.

1
Hello thevan please check a similar case under : forums.asp.net/t/997655.aspxNidheesh N Namboodhiri
@NidheeshNNamboodhiri: Yes. But I have more than 200 reports. Is there any other way to make it simple?thevan
You can use the Crystal Reports or the RAS SDK to accomplish this.craig

1 Answers

0
votes

Use the Crystal Reports SDK. Example.