cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Crystal Report Runtime, trying to run report from vb.net website

Sherry7
Discoverer
0 Kudos
345

I am trying to run a Crystal Report using Crystal Report Runtime in my vb.net website.  When the page loads into the browser, the report doesn't open.  I get no messages or errors, just an empty browser.  It behaves the same when I test it locally and on the server.  Why doesn't the runtime load the report?

Here's my source code in the .aspx file:

<%@ 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

Here are the added references and the file version:

Sherry7_0-1741697122135.png

Please help, I have tried different code from AI, but nothing works.

Thank you.

Accepted Solutions (1)

Accepted Solutions (1)

DonWilliams
Active Contributor
0 Kudos

You must use Sessions and PostBack to keep the report in scope.

See this KBA with example:

https://userapps.support.sap.com/sap/support/knowledge/en/1985571

Don

Sherry7
Discoverer
0 Kudos
Thank you Don, I will give this a try. I also found out that there is firewall on the database port and I have to get access to it. I will post back with final results.

Answers (0)