Solved

CRViewer displaying The report filename was empty.

Posted on 2011-02-25
4
2,974 Views
Last Modified: 2012-05-11
Thanks in advance for any input.
CRViewer is displaying The report filename was empty althought the report gets displayed accordingly.
I'm running a crystal report within VB.NET and using CRViewer to display the report.
Please at code and error message.


ASPX CODE:
<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPagePep.master" AutoEventWireup="false"
    CodeFile="reportsCrystal.aspx.vb" Inherits="reportsCrystal" %>

<%@ Register Assembly="CrystalDecisions.Web, Version=12.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"
    Namespace="CrystalDecisions.Web" TagPrefix="CR" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <div style="text-align: left; padding: 10px 0 10px 10px">
        <input id="btnBack" class="ButtonSmall" type="button" value="Back" onclick="javascript:history.back();" />
        <asp:Label ID="lblError" runat="server" Text="" ForeColor="Red"></asp:Label>
    </div>
    <div>
        <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="true"
            ReportSourceID="CrystalReportSource1" ToolPanelWidth="1px" />
        <CR:CrystalReportSource ID="CrystalReportSource1" runat="server">
        </CR:CrystalReportSource>
    </div>
</asp:Content>





VB CODE:
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports CrystalDecisions.Web
Imports CrystalDecisions.ReportSource
Imports System.Data
Imports System.Data.SqlClient
Imports CrystalDecisions.Reporting.WebControls
Imports System.IO

Partial Class reportsCrystal
    Inherits System.Web.UI.Page

    Dim _rpt As String = ""
    Dim _id As String = ""
    Protected timeout As Integer

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        getReport()

    End Sub

    Public Sub getReport()
        Try
            _rpt = Request.QueryString("rpt")
            _id = Request.QueryString("id")

            Dim objConn1 As New SqlConnection
            Dim oCom As New SqlCommand
            Dim dr As SqlDataReader

            objConn1.ConnectionString = System.Configuration.ConfigurationManager.AppSettings("ConnDB")
            oCom.Connection = objConn1
            objConn1.Open()
            oCom.CommandText = "sp_portal_CrystalReportUserAccessGet"
            oCom.CommandType = CommandType.StoredProcedure
            oCom.Parameters.Add(New SqlParameter("@userName", SqlDbType.NVarChar)).Value = Session("userName")
            oCom.Parameters.Add(New SqlParameter("@reportId", SqlDbType.Int)).Value = _id
            oCom.CommandTimeout = 150000
            dr = oCom.ExecuteReader

            If dr.Read Then
                If Session("userName") = dr("username") And _rpt = dr("reportName") Then
                    CrystalReportSource1.Report.FileName = "~/reportsCrystal/" & _rpt
                    lblError.Text = ""
                    CrystalReportViewer1.ViewTimeSelectionFormula = ""                  
                Else
                    lblError.Text = "Report access = 'NONE'"
                End If
            Else
                lblError.Text = "Report access = 'NONE'"
            End If
            objConn1.Close()
        Catch ex As Exception
            lblError.Text = ex.Message
        End Try
    End Sub
End Class

Open in new window

crystalerror.bmp
0
Comment
Question by:rborda
  • 2
4 Comments
 
LVL 17

Expert Comment

by:MIKE
ID: 34987887
What is the "REPORT NAME",....I don't see it in your code.....???
0
 
LVL 100

Accepted Solution

by:
mlmcc earned 500 total points
ID: 34988781
Look at this dialog from Crystal

http://forums.sdn.sap.com/thread.jspa?threadID=1355735

mlmcc
0
 

Author Comment

by:rborda
ID: 34997009
Hi CRXIuser2005:

The report name is passed thru the following field named _rpt  line 50 in the code

0
 

Author Closing Comment

by:rborda
ID: 34997799
Thank you mlmcc for the link provided. I want to clarify what helped me from the link.  Using the Page_Init instead of the page_Load to declare the path as indicated on the documentation.   Thank you again!
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question