Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a web app on the server and I get this error: Failed to open the connection. Failed to open the connection .rpt. I see the reports in the TEMP folder on the server but no connection. I created the reports in CR 2013 on the server. I add them to the web app in VS 2010 and put them in CRV on a web form. I noticed that my SQL 2005 Server Management Studio uses Windows Authentication to logon. But I can connect to the SQL database with CR 2013. Here is the code for the 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 System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Xml.Linq;
using System.Web.SessionState;
using CrystalDecisions.ReportAppServer;
using System.Drawing;
using System.Drawing.Printing;



namespace SACSCOCLogin1._1
{
    public partial class ReportFormA : 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("FormAReport.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.SetDatabaseLogon("Admin", "Enter", "SQL", "Hot");
            CrystalReportViewer1.ReportSource = CrystalReport;

        }
    }
}


What am I doing wrong? Please Help!!!
Posted

Try this thread[^].
 
Share this answer
 
I solved it!!!!!

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 System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Xml.Linq;
using System.Web.SessionState;
using CrystalDecisions.ReportAppServer;
using System.Drawing;
using System.Drawing.Printing;
 

 
namespace SACSCOCLogin1._1
{
    public partial class ReportFormA : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["HotConnectionString"].ConnectionString);
             con.Open();
            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("FormAReport.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.SetDatabaseLogon("Admin", "Enter", "SQL", "Hot");
            CrystalReportViewer1.ReportSource = CrystalReport;
            con.Close();
 
        }
    }
}

I just added the connection String and comment out the //CrystalReport.SetDatabaseLogon("Admin", "Enter", "SQL", "Hot");
 
Share this answer
 

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