HI i'm in a bit of a rush so sorry for the breif post.
I'm posting a chunk of code i have used and works to a degree, but i'm in
the process of trying to migrate to SQL Reporting Services.
Hopefully you can work your way through the logic (it isn't pretty but it
works in a production environment!)
Imports CrystalDecisions.Shared
Public Class AdobePrint
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
If Not Session("ReportLoc") Is Nothing Then
Dim FileName As String
Dim ExportPath As String
Dim dfdOptions As DiskFileDestinationOptions
Dim ExportOpts As ExportOptions
Dim OutputURL As String
Dim myreport As New ReportDocument()
If Not Session("ReportLoc") Is Nothing Then
FileName = Session("ReportLoc")
' FileName = FileName.Replace("Crystal_Reports", "Adobe_Reports")
If viewstate("ReportDoc") Is Nothing Then
viewstate.Add("ReportDoc", myreport)
myreport.Load(FileName)
SetDatabase(myreport)
SetParmaeters(myreport)
SetSelectionFourmula(myreport)
ExportPath = (Server.MapPath("AdobePrint.aspx").Replace("AdobeP rint.aspx",
"")) & "temp\" & Session("Username") & ".pdf"
'OutputFile = Server.MapPath("..\Reports\ExportedReports\" &
txtFileName.Text & OutputFileExtension)
OutputURL = "./temp/" & Session("Username") & ".pdf"
'Session.SessionID.ToString
dfdOptions = New DiskFileDestinationOptions
dfdOptions.DiskFileName = ExportPath
ExportOpts = myreport.ExportOptions
With ExportOpts
..DestinationOptions = dfdOptions
..ExportDestinationType = .ExportDestinationType.DiskFile
..ExportFormatType = .ExportFormatType.PortableDocFormat
End With
myreport.Export()
'With Response
' .ClearContent()
' .ClearHeaders()
' .ContentType = "application/pdf"
' .WriteFile(ExportPath)
' .Write("<HTML><HTML>")
' .Flush()
' .Close()
'End With
' System.IO.File.Delete(ExportPath)
Session.Remove("ReportLoc")
Response.Redirect(OutputURL)
End If
End If
End If
End Sub
#End Region
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
End Sub
Private Sub SetParmaeters(ByRef myreport As ReportDocument)
' If Not (Session("ReportDataDef") Is Nothing) Then
' 'Dim Param As CrystalDecisions.Shared.ParameterValues
' Dim DataDef As CrystalDecisions.CrystalReports.Engine.DataDefinit ion =
Session("ReportDataDef")
' Dim ParamFields As
CrystalDecisions.CrystalReports.Engine.ParameterFi eldDefinitions
' Dim ParamFD As ParameterFieldDefinition
' Dim ParamDis As New ParameterDiscreteValue()
' Dim i As Integer
' ParamFields = DataDef.ParameterFields
' For i = 0 To ParamFields.Count - 1
' myReport.DataDefinition.ParameterFields.apply()
'..CurrentValues(0) = ParamFields(i).CurrentValues(0)
' Next
' End If
If Not (Session("ReportDataDef") Is Nothing) Then
Dim DataDef As CrystalDecisions.CrystalReports.Engine.DataDefinit ion =
Session("ReportDataDef")
Dim ParamFields As ParameterFieldDefinitions
Dim paramValues As ParameterValues
Dim crParameterDiscreteValue As ParameterDiscreteValue
Dim i As Integer
ParamFields = DataDef.ParameterFields
For i = 0 To ParamFields.Count - 1
paramValues = ParamFields(i).CurrentValues
myReport.DataDefinition.ParameterFields.Item(i).Ap plyCurrentValues(paramValues)
Next
End If
End Sub
Private Sub SetSelectionFourmula(ByRef myreport As ReportDocument)
If Not (Session("ReportDataDef") Is Nothing) Then
Dim DataDef As CrystalDecisions.CrystalReports.Engine.DataDefinit ion =
Session("ReportDataDef")
myReport.DataDefinition.RecordSelectionFormula =
DataDef.RecordSelectionFormula
End If
End Sub
Private Sub SetDatabase(ByRef myreport As ReportDocument)
Dim CCI As Global.CrystalConnection = Application("CrystalDBInfo")
Dim RPTConnInfo As New ConnectionInfo()
With RPTConnInfo
..ServerName = CCI.Servername
..DatabaseName = CCI.Database
..UserID = CCI.UserID
..Password = CCI.PW
End With
Dim tblLogOnInfo As New TableLogOnInfo()
Dim myDB = myReport.Database
Dim myTbl = myDB.tables
Dim tbl As CrystalDecisions.CrystalReports.Engine.Table
For Each tbl In myReport.Database.Tables
tblLogOnInfo = tbl.LogOnInfo
tblLogOnInfo.ConnectionInfo = RPTConnInfo
tbl.ApplyLogOnInfo(tblLogOnInfo)
Next
End Sub
End Class
"Darrin" <Da****@discussions.microsoft.com> wrote in message
news:A4**********************************@microsof t.com...
Hello, I am looking for a web reporting solution. I have researched some
things on crystal reports but read that the version that is bundled with
Visual Studio 2003 does not allow you to print them. I was able to create
a
sample looking report in ASP.NET using VS2003 but not able to print it.
Is
there some specific code a person could use as I did not see a print
button.
I was thinking of creating my own reports but having a hard time with all
the
page break formatting.
Does the version of Crystal Reports bundled with VS2003 allow printing the
report from a ASP.NET web page? If so, what are the steps or do I need to
upgrade to another version of Cyrstal reports.
Otherwise, are there any other options out there for reporting. The
biggest
issue I have is setting the proper page breaks for a report that is sub
nested.
Any ideas or input would be appreciated.
Thanks,
Darrin