on 2023 Mar 13 6:38 AM
I am trying to filter record using 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.
The problem has nothing to do with the record selection formula. The issue is that either you're not explicitly logging in to the database or you're using the wrong credentials for your login.
For information about the correct way to log in to the database, see the links to sample code in the "Related Documents" section of the wiki.
-Dell
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
58 | |
10 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.