Click here to Skip to main content
15,064,072 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is my code, but it still give me login Failed.already i set EnableDatabaseLogonPrompt="False" in Crystal Report Viewer

What I have tried:

using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using CrystalDecisions.Web;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication1
    public partial class ReportViewer : System.Web.UI.Page
        protected void Page_Load(object sender, EventArgs e)
            if (!IsPostBack)
        private void LoadReport()
            string[] paths = { @"D:\CHAMINDA", "Project", "WebApplication", "WebApplication1", "WebApplication1", "SEC0001.rpt" };
            string fullPath = Path.Combine(paths);

            Session["ReportDocument"] = null;
            string rptName = fullPath;

            ReportDocument rptDoc = new ReportDocument();
            Session["ReportDocument"] = rptDoc;

            ReportDocument cryRpt = (ReportDocument)Session["ReportDocument"];
            TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
            TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
            ConnectionInfo crConnectionInfo = new ConnectionInfo();
            Tables CrTables;
                cryRpt.DataSourceConnections[0].SetConnection(@".\", "DMSSECURITY_WEB", true);
                cryRpt.DataSourceConnections[0].IntegratedSecurity = true;
                CrTables = cryRpt.Database.Tables;

                //crConnectionInfo.ServerName = "";
                //crConnectionInfo.DatabaseName = "DMSSECURITY_WEB";
                //crConnectionInfo.UserID = "sa";
                //crConnectionInfo.Password = "#compaq123";
                //crConnectionInfo.IntegratedSecurity = true;
                //CrTables = cryRpt.Database.Tables;

                foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
                    crtableLogoninfo = CrTable.LogOnInfo;
                    crtableLogoninfo.ConnectionInfo = crConnectionInfo;
                CrystalReportViewer1.ReportSource = cryRpt;

            catch (Exception ex)

                throw ex;

Updated 26-Nov-20 20:31pm

Maybe you can find more information here: Crystal Report Login Prompt[^]

It seems the good people at CodeProject are a bit tired of all those Crystal Report problems.
So if no one answers your question take a look at an alternative like FastReport,
see: open-source-reporting-tools[^]
Provide login info for each datatable in crystal report

With TblInfo.ConnectionInfo
            .ServerName = Utils.getConStr("Datasource")
            .DatabaseName = Utils.getConStr("DataBase")
            .UserID = Utils.getConStr("user")
            .Password = Utils.getConStr("pwd")
        End With

        With pReport
            .RecordSelectionFormula = ""
            For i As Integer = 0 To pReport.Subreports.Count - 1
                If .Subreports(i).Database.Tables.Count > 0 Then
                    '.Subreports(i).RecordSelectionFormula = ""
                End If
        End With

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900