Trying to run a Crystal Report from my vb.net website
I have written a website using Visual Studio 2022, vb.net. I am trying to run a Crystal Report from an .aspx file.
When I publish the page locally or on the server, all I get is a blank browser window. No errors, no messages. I don't know how to get the runtime to load the report. The report has a parameter, but I temporarily removed it to see if that was causing it not to load, but it didn't help.
I added the CrystalReportviewer and the CrystalReportSource to the file.
Here is the Source Code:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="PrintEmergencyRpt.aspx.vb" Inherits="Security_Badge_Requests.PrintEmergencyRpt" %>
<%@ Register assembly="CrystalDecisions.Web, Version=13.0.4000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" namespace="CrystalDecisions.Web" tagprefix="CR" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Crystal Report Viewer</title> <style type="text/css"> .auto-style1 {} </style> </head> <body> <form id="form1" runat="server"> <div> <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="true" ReportSourceID="CrystalReportSource1" /> <CR:CrystalReportSource ID="CrystalReportSource1" runat="server"> <Report FileName="~\AccessGrants-Emergency_Response.rpt"> </Report> </CR:CrystalReportSource> <br /> <asp:Button ID="Button1" runat="server" CssClass="auto-style1" Text="Button" Width="109px" /> <br /> </div> </form> </body> </html>
Here's the code in the aspx.vb file:
Imports CrystalDecisions.CrystalReports.Engine Imports CrystalDecisions.Shared
Public Class PrintEmergencyRpt Inherits System.Web.UI.Page
Protected Sub Page_init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init Dim tbCurrent1 As CrystalDecisions.CrystalReports.Engine.Table Dim tliCurrent1 As CrystalDecisions.Shared.TableLogOnInfo Dim cr As New CrystalDecisions.CrystalReports.Engine.ReportDocument()
Try 'Map the actual path on the server to the report file Dim strPath As String = Server.MapPath("AccessGrants-Emergency_Response.rpt") 'Load the report cr.Load(strPath, CrystalDecisions.Shared.OpenReportMethod.OpenReportByTempCopy)
For Each tbCurrent1 In cr.Database.Tables tliCurrent1 = tbCurrent1.LogOnInfo With (tliCurrent1.ConnectionInfo) .UserID = "xxxxx" .Password = "xxxxxxxxx" End With tbCurrent1.ApplyLogOnInfo(tliCurrent1) Next tbCurrent1
'Set the source for the report CrystalReportViewer1.ReportSource = cr Catch ex As Exception Response.Write("The Following Error has occurred: " & ex.InnerException.ToString) End Try
cr = Nothing End Sub
These are the references to Crystal Reports runtime: