Skip to Content
0
Former Member
Sep 19, 2007 at 07:02 PM

CrystalReportViewer

52 Views

Post Author: tjlague

CA Forum: .NET

I need assistance with CrystalReportViewer functionality. I have a report that displays on initial page load but when any of the CrystalReportViewer buttons are clicked the report prompts the user to authenticate. I would like to eliminate the authentication prompt. Below is my code: /////////////////////////////////Sample.aspx.cs 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.Shared;using CrystalDecisions.CrystalReports.Engine;using CrystalDecisions.Web;public partial class Sample : System.Web.UI.Page { private ReportDocument SampleReport; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ConfigureCrystalReports(); } } private void ConfigureCrystalReports() { ConnectionInfo connectionInfo = new ConnectionInfo(); connectionInfo.ServerName = "server"; connectionInfo.DatabaseName = "database"; connectionInfo.UserID = "user"; connectionInfo.Password = "password"; SampleReport = new ReportDocument(); string reportPath = Server.MapPath("Reports/Sample.rpt"); SampleReport .Load(reportPath); SetDBLogonForReport(connectionInfo, SampleReport); CrystalReportViewer1.ReportSource = SampleReport; } 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); } } } /////////////////////////////////Sample.aspx <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Sample.aspx.cs" Inherits="Sample" %><%@ Register TagPrefix="CR" Namespace="CrystalDecisions.Web" Assembly="CrystalDecisions.Web, Version=11.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" %> http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

xmlns=" http://www.w3.org/1999/xhtml" > Any assistance is appreciated. Code examples are preferred. Thanks!