Recently I was successful in retrieving a report from the crystal enterprise 10 server and display it on an asp.net 2.0 Page. Certain reports (those with subreports I suspect) return an "Invalid Pointer" error to the viewer.
Question 1:
How can I display these reports that have subreports
Question 2:
How can I replace the CrystalReportsViewer .Net Control with the ActiveX Viewer (Due to a customer's request)
My Code is as follows
**************.aspx********************
<%
@ Page Language="VB" AutoEventWireup="false" CodeFile="Default3.aspx.vb" Inherits="Default3" %>
<%
@ Register Assembly="CrystalDecisions.Web, Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"
Namespace="CrystalDecisions.Web" TagPrefix="CR" %>
<!
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml">
<
head runat="server">
<title>Untitled Page</title>
</
head>
<
body>
<form id="form1" runat="server">
<div>
<asp:ListBox ID="ListBox1" runat="server" Height="344px">
<!--List of Report Titles Go here-->
</asp:ListBox>
<asp:Button ID="Button1" runat="server" Text="Button" /><br />
<br />
<CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="true">
</CR:CrystalReportViewer>
</div>
</form>
</
body>
</
html>
**************.aspx.vb********************
Imports
CrystalDecisions.Enterprise
Imports
CrystalDecisions.ReportAppServer.ClientDoc
Imports
CrystalDecisions.Shared
Imports
CrystalDecisions.Enterprise.Desktop
Imports
CrystalDecisions.Enterprise.Viewing
Imports
CrystalDecisions.ReportAppServer.Controllers
Imports
CrystalDecisions.ReportAppServer
Partial
Class Default3
Inherits System.Web.UI.Page
Dim ceSession As EnterpriseSession
Dim ceEnterpriseService As EnterpriseService
Dim ceInfoStore As InfoStore
Dim ceReportObjects As InfoObjects
Dim ceReportObject As InfoObject
Dim ceReport As Report
Dim sQuery As String
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ceSessionMgr As SessionMgr = New SessionMgr
'logon to Enterprise
ceSession = ceSessionMgr.Logon(
"Username", "Password", "ServerName", "secEnterprise")
'Create the infostore object
ceEnterpriseService = ceSession.GetService(
"", "InfoStore")
ceInfoStore =
New InfoStore(ceEnterpriseService)
'check for reports on server
sQuery =
"Select * From CI_INFOOBJECTS Where SI_PROGID = 'CrystalEnterprise.Report' AND SI_Name='" & ListBox1.SelectedItem.Text & "'" 'Lease_Portfolio_Activity'"
ceReportObjects = ceInfoStore.Query(sQuery)
'check for returned reports
If ceReportObjects.Count > 0 Then
ceReportObject = ceReportObjects.Item(1)
ceReport =
CType(ceReportObject, Report)
ceEnterpriseService = ceSession.GetService(
"RASReportFactory")
Dim rrfObject As Object = ceEnterpriseService.Interface
Dim myReportAppFactory As ReportAppFactory = CType(rrfObject, ReportAppFactory)
Dim myReportClientDocument As ReportClientDocument = New ReportClientDocumentClass()
myReportClientDocument = myReportAppFactory.OpenDocument(ceReportObject.ID, 0)
CrystalReportViewer1.ReportSource = myReportClientDocument
CrystalReportViewer1.Visible =
True
Else
'no objects returned by query
Response.Write(
"No report objects found by query <br>")
Response.Write(
"Please click <a href='Index.aspx'>here</a> to return to the logon page.<br>")
End If
ceSession.Dispose()
ceEnterpriseService =
Nothing
ceInfoStore.Dispose()
ceReportObjects.Dispose()
ceReportObject.Dispose()
ceReport.Dispose()
ceParameterFields =
Nothing
ceParameterField =
Nothing
ceParameterDiscreteValue =
Nothing
ceParameterRangeValue =
Nothing
ceParameters.Dispose()
ceParameter.Dispose()
ceSessionMgr.Dispose()
End Sub
Any help would be highly apperciated.