I have a web form that has crystal report viewer on it. It works on the test environment. When it is on the server it won't display. Error shows Database Logon Failed. I created the report with Crystal Report 2013. I then imported it into the project and add it to the report viewer. Here is the code behind the report viewer that loads the report and logs into the database.
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 ReportFormD : 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("FormDReport.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", "password", "SQL Server", "Hot");
CrystalReportViewer1.ReportSource = CrystalReport;
}
}
}
Is there something wrong with my code? What did I do wrong?
Here is my Web.config file:
<appSettings>
<add key="CrystalImageCleaner-AutoStart" value="true" />
<add key="CrystalImageCleaner-Sleep" value="60000" />
<add key="CrystalImageCleaner-Age" value="120000" />
<add key="resourceURI" value="~/aspnet_client/system_web/4_0_30319/crystalreportviewers13" />
</appSettings>
<connectionStrings>
<add name="HotConnectionString" connectionString="Data Source=SQL Server;Initial Catalog=Hot;Integrated Security=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<httpHandlers>
<add path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" validate="false"/>
<add verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
</httpHandlers>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="Microsoft.ReportViewer.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="Microsoft.Build.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
<add assembly="CrystalDecisions.Shared, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
<add assembly="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
<add assembly="CrystalDecisions.ReportSource, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
<add assembly="CrystalDecisions.ReportAppServer.Controllers, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
<add assembly="CrystalDecisions.ReportAppServer.DataDefModel, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
<add assembly="CrystalDecisions.CrystalReports.Engine, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
<add assembly="CrystalDecisions.ReportAppServer.ClientDoc, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/></assemblies>
<buildProviders>
<add extension=".rpt" type="CrystalDecisions.Web.Compilation.RptBuildProvider, CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
</buildProviders>
</compilation>
<pages maintainScrollPositionOnPostBack="true"/>
<customErrors mode="Off" defaultRedirect="Oops.aspx"/>
<authentication mode="Forms">
<forms loginUrl="/Login.aspx"/>
</authentication>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<handlers>
<add name="ReportViewerWebControlHandler" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
<add name="CrystalImageHandler.aspx_GET" verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" preCondition="integratedMode"/>
</handlers>
</system.webServer>
</configuration>
Does all of the code look ok?