Solved

CRViewer displaying The report filename was empty.

Posted on 2011-02-25
4
2,887 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

757 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now