Search code examples
asp.netcrystal-reports

How to show Crystal Report preview without SQL Server log in authentication?


In asp.net 4.0, when we create report in Crystal Reports using ADO.NET objects, we face a problem that after successfully creating the report preview, the report wants a user id and password for SQL Server. How can I solve this?

When I want to attached ADO.NET object in Crystal Reports it wants an XML file. How can I configure or connect it?


Solution

  • Hey Please refer this code to Resolve your Problem

    protected void Page_Load(object sender, EventArgs e)
    {
    ReportDocument crystalReport = new ReportDocument();
    crystalReport.Load(Server.MapPath("CrystalReport.rpt"));
    crystalReport.SetDatabaseLogon("username", "password", @"server name", "DB name");
    CrystalReportViewer1.ReportSource = crystalReport;
    }
    

    hope it will help