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

Dani AI

Generated

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:

  • Turn off "Save Data with Report" and use "Verify Database" in the designer if moving environments.
  • If using ODBC/DSN, ensure the DSN exists on the server with the same name.
  • For Windows authentication, either run the app pool identity with DB rights or use impersonation; otherwise use SQL auth credentials.
  • Match Crystal runtime versions between development and server.
  • Never hardcode plain credentials in code; use an encrypted config store or secure vault.
  • Dispose the ReportDocument (Close/Dispose) after use to avoid leaks.

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");
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.