Dear Group,

Alright, I decided to write to the group after wasting a week of
precious time all at vain. I have to fix this and move on with my life
and of people around me.

My crystal report page works neat and fine in localhost, but gives a
"database logon fail" when deployed.
Development and Deployment system are the same ( I work for a small
business). I have all bells and whistles, Licensed CR, VS2008, SQL
2008, Windows 2008 R2.

I connect my reportviewer with a crystalreport source. I have a stored
procedure in the DB. Crystal reports calls that sproc directly along
with a parameter from front end. (See C# and ASP code below). Thanks a
lot guys.....

========================================================================

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using System.Collections.Specialized;
using System.util;

public partial class sample : System.Web.UI.Page
{
    ReportDocument reportDocument = new ReportDocument();
    ParameterField paramField = new ParameterField();
    ParameterFields paramFields = new ParameterFields();
    ParameterDiscreteValue paramDiscreteValue = new
ParameterDiscreteValue();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            paramField.Name = "@ProgramName";
            paramDiscreteValue.Value = "Dubai-2009";
            paramField.CurrentValues.Add(paramDiscreteValue);
            paramFields.Add(paramField);
            CrystalReportViewer1.ParameterFieldInfo = paramFields;
            reportDocument.Load(Server.MapPath("missingdoc.rpt"));
            System.Data.SqlClient.SqlConnectionStringBuilder SConn =
new
System.Data.SqlClient.SqlConnectionStringBuilder(ConfigurationManager.ConnectionStrings["STDABD_BAKConnectionStringSECURE"].ConnectionString);
            //CrystalReportViewer1.ReportSource = reportDocument;
            reportDocument.SetDatabaseLogon(SConn.UserID,
SConn.Password, SConn.DataSource, SConn.InitialCatalog);

        }
    }

    protected void Button1_Click1(object sender, EventArgs e)
    {
        paramField.Name = "@ProgramName";
        paramDiscreteValue.Value =
DropDownList1.SelectedValue.ToString();
        paramField.CurrentValues.Add(paramDiscreteValue);
        paramFields.Add(paramField);
        CrystalReportViewer1.ParameterFieldInfo = paramFields;
        reportDocument.Load(Server.MapPath("missingdoc.rpt"));
        System.Data.SqlClient.SqlConnectionStringBuilder SConn = new
System.Data.SqlClient.SqlConnectionStringBuilder(ConfigurationManager.ConnectionStrings["STDABD_BAKConnectionStringSECURE"].ConnectionString);
        //CrystalReportViewer1.ReportSource = reportDocument;
        reportDocument.SetDatabaseLogon(SConn.UserID, SConn.Password,
SConn.DataSource, SConn.InitialCatalog);
    }

}
=======================================================================
ASP code:

<form id="form1" runat="server">
                <CR:CrystalReportSource ID="CrystalReportSource1"
runat="server">
                    <Report FileName="missingdoc.rpt">
                    </Report>
                </CR:CrystalReportSource>

                    <asp:DropDownList ID="DropDownList1"
runat="server"
                        DataSourceID="SqlDataSource2"
DataTextField="ProgramName"
                        DataValueField="ProgramName"
AutoPostBack="False">
                                   </asp:DropDownList>

                    <asp:SqlDataSource ID="SqlDataSource2"
runat="server"
                        ConnectionString="<%$
ConnectionStrings:STDABD_BAKConnectionStringSECURE %>"

                        SelectCommand="SELECT DISTINCT ProgramName
FROM StudentInfo ORDER BY ProgramName DESC">
                    </asp:SqlDataSource>
                <br />
                <asp:Button ID="Button1" runat="server" Text="Generate
Report"
                    onclick="Button1_Click1" />
                <br />
    <br />
                <CR:CrystalReportViewer ID="CrystalReportViewer1"
runat="server"
                    AutoDataBind="True"
EnableDatabaseLogonPrompt="False"
                    Height="1158px" ToolbarImagesFolderUrl=""
                    ToolPanelWidth="200px" Width="1059px"
                    ReportSourceID="CrystalReportSource1"
ToolPanelView="None" />
                </form>

Reply via email to