I am trying to filter record using ASP.NET MVC 5 with ReportDocument RecordSelectionFormula, but I am getting error:
CrystalDecisions.CrystalReports.Engine.LogOnException: 'Database logon failed.'
inner Exception COMException: Database logon failed.
My code is given bellow here
string Examtype = Request.Form["Examtype"];
string ExamYear = "1444";
string DarjaID = Request.Form["DarjaID"];
string Regid = Convert.ToString(Session["Regid"]);
ReportDocument rd = new ReportDocument();
string relativePath = Server.MapPath("~") + "Reports/Rolnoslips/RolnoslipBnat.rpt";
rd.Load(relativePath);
rd.RecordSelectionFormula = $@"{{StudentIncentreWRoll.Courseid}} = ""{DarjaID}"" and
{{StudentIncentreWRoll.Regid}} = ""{Regid}"" and
{{StudentIncentreWRoll.Status}} <> ""0"" ";
rd.SetDatabaseLogon(db._UserName, db._Password, db._ServerName, db._DataBase);
//rd.Refresh();
Response.Buffer = false;
Response.ClearContent();
Response.ClearHeaders();
Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
stream.Seek(0, SeekOrigin.Begin);
Response.AppendHeader("Content-Disposition", $"inline; filename=Rolnoslips-{DateTime.Now}.pdf");
return File(stream, "application/pdf");
When I click on "save data in report" in Main Report Preview, the report is loaded successfully but show only save data, not show the required filter record.
How use RecordSelectionFormula & refresh the report?
Also when I try to uncomment rd.Refresh(), facing given below error
inner Exception COMException: Database logon failed.