Sachin Trivedi
Sachin Trivedi

Reputation: 2053

Crystal Report Error : "Missing Param Values" while providing param from codebehind

I'm using crystal reports in my web application. My problem is when i keep EnableDatabaseLogonPrompt="true" and EnableParameterPrompt="true" and provide information in prompted box my report works fine. but when i keep them false and provide information from code behind it always gives an error that "Missing Param Values" or "Database Logon Failed".

My code is as below :

Aspx file:

       <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" 
            AutoDataBind="True" 
            GroupTreeImagesFolderUrl="" Height="1202px" 
            ReportSourceID="CrystalReportSource1" ReuseParameterValuesOnRefresh="True" 
            ToolbarImagesFolderUrl="" ToolPanelWidth="200px" Width="903px" 
            ToolPanelView="None" EnableDatabaseLogonPrompt="False" 
            EnableParameterPrompt="False" />
        <CR:CrystalReportSource ID="CrystalReportSource1" runat="server">
            <Report FileName="CrystalReport1.rpt">
            </Report>
        </CR:CrystalReportSource>

Code Behind:

       ReportDocument reportDocument = new ReportDocument();           
       reportDocument.Load(Server.MapPath("~/CrystalReport1.rpt"));
       string s=@"4EVER3-PC\MSSQLSERVER2";
       reportDocument.SetDatabaseLogon("db", "pwd", s, "databasename", true);
       reportDocument.SetParameterValue("@bankACId", "0");
       reportDocument.SetParameterValue("@fromDate", "4/11/2011 17:01:57");
       reportDocument.SetParameterValue("@todate", "4/11/2014 17:01:57");

       CrystalReportViewer1.ReportSource = reportDocument;
       CrystalReportViewer1.RefreshReport();

please make a point what is wrong with this code. it is drivig me crazy.

Upvotes: 1

Views: 1098

Answers (2)

Sachin Trivedi
Sachin Trivedi

Reputation: 2053

resolved the logon failed error.

I was accessing the database from another pc and its firewall was not allowing me to connect through crystal report. so i added sql server management studio to the list of allowed programs by firewall. So now connection problem is resolved.

So crystal report without any parameter works fine. but when i pass parameters it force closes the debug server..Any idea what should be the problem.

This is the half answer of my question which may be helpful to those who are facing connection problems.

Upvotes: 1

Chetan Sanghani
Chetan Sanghani

Reputation: 2111

Aspx FIle :

  <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" 
            AutoDataBind="True" 
            Height="1202px" 
            ReportSourceID="CrystalReportSource1" />
        <CR:CrystalReportSource ID="CrystalReportSource1" runat="server">
            <Report FileName="CrystalReport1.rpt">
            </Report>
        </CR:CrystalReportSource>

Code Behind :

 protected void btnShowReport_Click(object sender, EventArgs e)
    {
       LoadReport();           
    }

    private void LoadReport()
    {
        doc = new ReportDocument();
        doc.Load(Server.MapPath("CrSalesReport.rpt"));

        doc.SetDatabaseLogon(AppConfig.ReportServerDSUserName, AppConfig.ReportServerDSPassword, AppConfig.ReportServerDomain, "TexERP", false);

   doc .SetParameterValue("@bankACId", "0");
   doc .SetParameterValue("@fromDate", "4/11/2011 17:01:57");
   doc .SetParameterValue("@todate", "4/11/2014 17:01:57");

        CrystalReportViewer1.ReportSource = doc;
    }

Upvotes: 0

Related Questions