Solved

CRViewer displaying The report filename was empty.

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
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…

770 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