!!! REPORTS WORKING !!! I have finally got all my reports working. I'd like to thank everyone who posted to this thread from the bottom of my ASP.NET book (read: heart)!! (Including Brian) I'll post a final message explaining everything so that future readers
can see the full solution. Thank you! Ron.
Yipee! Now that your users can see the reports, here some the changes... On another note, when I use an ADO.NET dataset, I have found it easiest to use a stored procedure for my queries. You can simply drag the SP from the server explorer onto a blank XSD and
it will automatically generate the schema for you.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim rptSummary As ReportDocument
Dim strExportFile As String
Dim objExOpt As ExportOptions
Dim objDiskOpt As New DiskFileDestinationOptions
strExportFile = "blankreview.pdf"
' Declare Report
Dim rptBlank As New crBlankSR
' Selection string for Data Adapter
Dim strSQL As String = "SELECT * from tblQuestions where QuestionYear = '" & Session("FY") & "' ORDER BY QuestionNbrID"
' Open Connection
SqlCon.Open()
' Delcare Adapter
Dim da As SqlDataAdapter
' Instantiate Adapter
da = New SqlDataAdapter(strSQL, SqlCon)
' Declare Data Set
Dim ds As datasetBlankSR ' *** 1st Run I have DataSet Here
' Instantiate Data Set
ds = New datasetBlankSR ' *** 1st Run I have DataSet Here
' Fill Data Set
da.Fill(ds, "tblQuestions")
ds.WriteXMLSchema("datasetBlankSR.xsd") ' *** Remove this after 1st Run
' Set Report Data Source
rptBlank.SetDataSource(ds)
rptSummary = rptBlank
objDiskOpt.DiskFileName = Server.MapPath(".") & "\" & strExportFile
objExOpt = rptSummary.ExportOptions
objExOpt.ExportDestinationType = ExportDestinationType.DiskFile
objExOpt.ExportFormatType = ExportFormatType.PortableDocFormat
objExOpt.DestinationOptions = objDiskOpt
rptSummary.Export()
rptSummary.Close()
' Close Connection
SqlCon.Close()
' Make sure all connections, readers and commands are closed
ds.Dispose()
da.Dispose()
If SqlCon.State <> ConnectionState.Closed Then SqlCon.Close()
' Send user to PDF report
Response.Redirect(strExportFile)
End Sub
After this runs once I remove or change the noted lines and create a Crystal Report called crBlankSR.rpt and use the
dataset that [ds.WriteXMLSchema("datasetBlankSR.xsd")] created as my datasource. After designing and tweaking the report I run the app again and the report is exported to PDF and all is well in the world. Hope this helps anyone out there with the same issues.
Thanks for all the help guys. Ron. BTW: I have a disclaimer on my report that states "No one is allowed to ask for changes EVER!!!" hehe
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
What code are you using to save the report? View this
article for some code on how to load the report. Also, check out the Home link on that page for more links to useful articles. And check out support.businessobjects.com for more walkthroughs for Crystal. HTH
Eric Landes
MADNUG President http://www.madnug.net
Crystal Alliance Editor
Blog http://aspadvice.com/blogs/elandes
Microsoft MVP
ericlandes
Contributor
5475 Points
1095 Posts
ASPInsiders
MVP
Re: Trying to Convert to PDF - Help
Oct 25, 2004 03:33 PM|LINK
MADNUG President http://www.madnug.net
Crystal Alliance Editor
Blog http://aspadvice.com/blogs/elandes
Microsoft MVP
Capt_Ron
Member
586 Points
139 Posts
Re: Trying to Convert to PDF - Help
Oct 25, 2004 05:13 PM|LINK
rjdudley
Star
10145 Points
1976 Posts
ASPInsiders
Re: Trying to Convert to PDF - Help
Oct 25, 2004 06:19 PM|LINK
Capt_Ron
Member
586 Points
139 Posts
Re: Trying to Convert to PDF - Help
Oct 28, 2004 11:33 PM|LINK
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim rptSummary As ReportDocument Dim strExportFile As String Dim objExOpt As ExportOptions Dim objDiskOpt As New DiskFileDestinationOptions strExportFile = "blankreview.pdf" ' Declare Report Dim rptBlank As New crBlankSR ' Selection string for Data Adapter Dim strSQL As String = "SELECT * from tblQuestions where QuestionYear = '" & Session("FY") & "' ORDER BY QuestionNbrID" ' Open Connection SqlCon.Open() ' Delcare Adapter Dim da As SqlDataAdapter ' Instantiate Adapter da = New SqlDataAdapter(strSQL, SqlCon) ' Declare Data Set Dim ds As datasetBlankSR ' *** 1st Run I have DataSet Here ' Instantiate Data Set ds = New datasetBlankSR ' *** 1st Run I have DataSet Here ' Fill Data Set da.Fill(ds, "tblQuestions") ds.WriteXMLSchema("datasetBlankSR.xsd") ' *** Remove this after 1st Run ' Set Report Data Source rptBlank.SetDataSource(ds) rptSummary = rptBlank objDiskOpt.DiskFileName = Server.MapPath(".") & "\" & strExportFile objExOpt = rptSummary.ExportOptions objExOpt.ExportDestinationType = ExportDestinationType.DiskFile objExOpt.ExportFormatType = ExportFormatType.PortableDocFormat objExOpt.DestinationOptions = objDiskOpt rptSummary.Export() rptSummary.Close() ' Close Connection SqlCon.Close() ' Make sure all connections, readers and commands are closed ds.Dispose() da.Dispose() If SqlCon.State <> ConnectionState.Closed Then SqlCon.Close() ' Send user to PDF report Response.Redirect(strExportFile) End SubAfter this runs once I remove or change the noted lines and create a Crystal Report called crBlankSR.rpt and use the dataset that [ds.WriteXMLSchema("datasetBlankSR.xsd")] created as my datasource. After designing and tweaking the report I run the app again and the report is exported to PDF and all is well in the world. Hope this helps anyone out there with the same issues. Thanks for all the help guys. Ron. BTW: I have a disclaimer on my report that states "No one is allowed to ask for changes EVER!!!" heheredice
Member
500 Points
110 Posts
Re: Trying to Convert to PDF - Help
Apr 21, 2005 02:57 AM|LINK
Hi all,
I have no idea where to place these codes:
Imports System.Data
Imports System.Data.SqlClient
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports System.IO
redice
Member
500 Points
110 Posts
Re: Trying to Convert to PDF - Help
Apr 21, 2005 03:15 AM|LINK
Hi,
Nevermind, I knew where to place them, but I still get errors... [:'(]
redice
Member
500 Points
110 Posts
Re: Trying to Convert to PDF - Help
Apr 21, 2005 03:19 AM|LINK
Yo,
This is the error:
Load report failed.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: CrystalDecisions.CrystalReports.Engine.LoadSaveReportException: Load report failed.
I have no idea why. Please help me... [:P]
ericlandes
Contributor
5475 Points
1095 Posts
ASPInsiders
MVP
Re: Trying to Convert to PDF - Help
Apr 21, 2005 12:40 PM|LINK
MADNUG President http://www.madnug.net
Crystal Alliance Editor
Blog http://aspadvice.com/blogs/elandes
Microsoft MVP