|
-
Jan 19th, 2005, 02:13 PM
#1
Thread Starter
Frenzied Member
Baffled by Crystal to PDF in ASP.NET
Exporting a Crystal Report to a PDF file using ASP.NET. It works ok, but the page doesn't seem to load the first time. I end up having to hit refresh for it to come up. Oddly, with a break point in my Page_Load event, when I hit refresh it runs the function twice. Anybody have any ideas? Here's the code.
Thanks.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
' Define Crystal Reports variables
Dim crReportDocument As ReportDocument
Dim SQLConn As SqlClient.SqlConnection ' SQL Connection
Dim SQLDA As SqlClient.SqlDataAdapter ' SQL Data Adapter
Dim dsDataSet As New DataSet ' Dataset
Dim strSQL As String ' SQL Statement
Dim oStream As System.IO.MemoryStream
' Instantiate the SQL Connection
SQLConn = New SqlClient.SqlConnection("Persist Security Info=False;server=MyServer;database=MyDB;User ID=sa;Password=password")
' SQL SELECT Statement
strSQL = "SELECT * FROM Tasks ORDER BY DueDate"
' Instantiate the SQL DataAdapter
SQLDA = New SqlClient.SqlDataAdapter(strSQL, SQLConn)
' Populate the DataSet
SQLDA.Fill(dsDataSet, "Tasks")
' Instantiate the Crystal Report Document (crTasks.rpt)
crReportDocument = New crTasks
Try
' Set the DataSource for the Report as the DataSet
crReportDocument.SetDataSource(dsDataSet)
Catch ex As Exception
End Try
oStream = crReportDocument.ExportToStream(ExportFormatType.PortableDocFormat)
Response.Clear()
Response.ContentType = "application/pdf"
Response.Buffer = True
Response.BinaryWrite(oStream.ToArray())
Response.Flush()
Response.Close()
End Sub
Sean
Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.
-
Jan 20th, 2005, 10:37 AM
#2
Thread Starter
Frenzied Member
Re: Baffled by Crystal to PDF in ASP.NET
Man this is frustrating, anybody have any thoughts?
Sean
Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|