无法打开连接.无法打开连接. [英] Failed to open the connection. Failed to open the connection.
问题描述
我在服务器上有一个Web应用程序,但出现此错误:无法打开连接.无法打开连接.rpt.我在服务器的TEMP文件夹中看到报告,但没有连接.我在服务器上的CR 2013中创建了报告.我将它们添加到VS 2010中的Web应用程序中,然后将它们放入CRV中的Web表单中.我注意到我的SQL 2005 Server Management Studio使用Windows身份验证进行登录.但是我可以使用CR 2013连接到SQL数据库.这是CRV的代码:
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:
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!!!
推荐答案
尝试此线程 [< ^ ].
我解决了!!!!!
I solved it!!!!!
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();
}
}
}
我只是添加了连接字符串,并注释了//CrystalReport.SetDatabaseLogon("Admin," Enter," SQL," Hot);
I just added the connection String and comment out the //CrystalReport.SetDatabaseLogon("Admin", "Enter", "SQL", "Hot");
这篇关于无法打开连接.无法打开连接.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!