Click here to Skip to main content
15,064,665 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a web form that has a Crystal Report Viewer on it. When the print button is clicked on the development computer the web page displays the report and everything works and looks good. When I put it on the sever, Windows Server 2012 with IIS 8, and click the print button the web page comes up with an error saying:

HTML
Failed to open the connection. Failed to open the connection. FormAReport {4227EE7A-30FE-48B6-A305-2A2F887E857C}.rpt


The report loads by a session. The session goes by the users ID number. I know the report works on the development computer but why doesn't it work for the server?

I used CR 2013 to make the report. I also used the Report, Select Expert, Record. Within that I used this formula: {TableCOCINST.INST_ID} = {?inst_id}.

Here is the code for the report to load in CRV:

C#
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using CrystalDecisions.Web;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.WebControls;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using CrystalDecisions.Windows.Forms;
using CrystalDecisions.ReportSource;
using CrystalDecisions.ReportAppServer;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Xml.Linq;
using System.Web.SessionState;

namespace SACSCOCLogin1._1
{
    public partial class ReportFormFTE : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            TextBoxINST_ID.Text = Session["inst_id"].ToString();
            CrystalReportViewer1.Visible = true;

            ReportDocument CrystalReport = new ReportDocument();
            ParameterField paramField = new ParameterField();
            ParameterFields paramFields = new ParameterFields();
            ParameterDiscreteValue paramDiscreteValue = new ParameterDiscreteValue();

            paramField.Name = "inst_id";
            paramField.CurrentValues.Clear();
            paramDiscreteValue = new ParameterDiscreteValue();
            paramDiscreteValue.Value = TextBoxINST_ID.Text;
            paramFields.Add(paramField);
            CrystalReportViewer1.ParameterFieldInfo = paramFields;

            CrystalReport.Load(Server.MapPath("FormFTEReport.rpt"));
            string sessiontype = TextBoxINST_ID.Text;
            CrystalReport.SetParameterValue("inst_id", TextBoxINST_ID.Text);

            string sessionid = TextBoxINST_ID.Text;
            CrystalReport.SetParameterValue("inst_id", TextBoxINST_ID.Text);
            //CrystalReport.Refresh();
            CrystalReport.SetDatabaseLogon("LocalAccount", "passsword", @"SQLData", "Database1");
            CrystalReportViewer1.ReportSource = CrystalReport;
        }
    }
}


What did I do wrong?
Posted
Comments
j snooze 9-Apr-14 17:40pm
   
which line is the code failing on? does the webserver have access to the SQL database? If its a local database on your machine, my guess is no.
Computer Wiz99 9-Apr-14 18:16pm
   
There is no line the code fails on from what I can see. Yes the webserver does have access to the SQL database. My local machine is connected to the SQL database. It works on my computer when developing but not on the Windows Server 2012. I also have Crystal Reports 2013 and IIS 8.
thatraja 11-Apr-14 7:16am
   
Make sure you're using the right server logon details. I think you forgot to change logon details in your web.config

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900