Hi
I want to write asp.net page with crystal reports.I pass parameter to reports.Once I press submit button its ask database user name and password.How I stop asking user name and password in every time.
Thanks
Tank50
Crystal Reports asks for a database login when the running report still points to a saved datasource or when some tables/subreports never received credentials at runtime. 's suggestion to configure the report source is a useful start, but the common gap is failing to apply logon info to every table and to each subreport. The reliable fix is to build a ConnectionInfo and apply it to all report tables and subreport tables before assigning the ReportDocument to the viewer.
Example (C#) that applies credentials to main tables and any subreports:
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
var report = new ReportDocument();
report.Load(Server.MapPath("~/Reports/MyReport.rpt"));
var conn = new ConnectionInfo {
ServerName = "SERVER",
DatabaseName = "DB",
UserID = "sqluser",
Password = "sqlpass"
};
foreach (CrystalDecisions.CrystalReports.Engine.Table table in report.Database.Tables)
{
var tli = table.LogOnInfo;
tli.ConnectionInfo = conn;
table.ApplyLogOnInfo(tli);
}
foreach (Section section in report.ReportDefinition.Sections)
{
foreach (ReportObject repObj in section.ReportObjects)
{
if (repObj.Kind == ReportObjectKind.SubreportObject)
{
var sub = (SubreportObject)repObj;
var subDoc = sub.OpenSubreport(sub.SubreportName);
foreach (CrystalDecisions.CrystalReports.Engine.Table table in subDoc.Database.Tables)
{
var tli = table.LogOnInfo;
tli.ConnectionInfo = conn;
table.ApplyLogOnInfo(tli);
}
}
}
}
CrystalReportViewer1.ReportSource = report; Checklist and cautions:
These steps address the usual causes of repeated login prompts.
How I stop asking user name and password in every time.
Configure the reportSource object,
CrystalReportSource1.ReportDocument.SetDatabaseLogon("username", "password","server_instance","database_name"); We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.