728x90

Re: Crystal Report Asking for Database Authentication each time when I view Page.

Jan 17, 2008 11:20 AM|LINK

Hi Asif,

Set the logon information in you code as shown below. Use this code approach instead.

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;

public partial class _Default : System.Web.UI.Page 
{
    private ReportDocument rpt;

    private void Page_Init(object sender, EventArgs e)
    {
        ConfigureCrystalReports();
    }
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    private void ConfigureCrystalReports()
    {
        rpt= new ReportDocument();
        string reportPath = Server.MapPath("youreportname.rpt");
        rpt.Load(reportPath);
        ConnectionInfo connectionInfo = new ConnectionInfo();
        connectionInfo.DatabaseName = "Northwind";
        connectionInfo.UserID = "user";
        connectionInfo.Password="user123";
        SetDBLogonForReport(connectionInfo,rpt);
        CrystalReportViewer1.ReportSource = rpt;
    }
    private void SetDBLogonForReport(ConnectionInfo connectionInfo, ReportDocument reportDocument)
    {
        Tables tables = reportDocument.Database.Tables;
        foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)
        {
            TableLogOnInfo tableLogonInfo = table.LogOnInfo;
            tableLogonInfo.ConnectionInfo = connectionInfo;
            table.ApplyLogOnInfo(tableLogonInfo);
        }
    }
}


출처 : http://forums.asp.net/t/1206308.aspx?Crystal+Report+Asking+for+Database+Authentication+each+time+when+I+view+Page+


728x90

'C#' 카테고리의 다른 글

c# datagridview textalign  (0) 2014.07.13
c# treeview 마우스 우클릭  (0) 2014.07.13
c# ini  (0) 2014.07.04
크리스탈리포트 개발 방법  (0) 2014.07.03
크리스탈리포트 setParamenterValue  (0) 2014.07.03

+ Recent posts