473,396 Members | 2,089 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Crystal Reports or other for ASP.NET web

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

Nov 7 '05 #1
2 2342
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

Nov 8 '05 #2
Thanks for the code snippet. I'll see if I can work my way through it.

"Namshub" wrote:
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


Nov 9 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: rAGHU | last post by:
Hi, In my ASP.NET web application project we need to design crystal reports with Crystal Reports version 8.5 enterpraise edition(Please Note:It is not the Crystal Reports that comes with...
1
by: Stephan | last post by:
Hi, I'm using Visual Studio 2003 (C#) with the integrated Crystal Report software and have the following question: How can I assign a value (string) to an unbound (string) field in Crystal...
4
by: Rich Moser | last post by:
My organization is in the midst of making a reporting tool decision. On the table are Crystal and the reporting functionality in Access. - Report distribution is not a factor - it's all local -...
7
by: p | last post by:
WE had a Crystal 8 WebApp using vs 2002 which we upgraded to VS2003. I also have Crystal 9 pro on my development machine. The web app runs fine on my dev machine but am having problems deploying....
19
by: LP | last post by:
I am using (trying to) CR version XI, cascading parameters feature works it asks user to enter params. But if page is resubmitted. It prompts for params again. I did set...
7
by: John | last post by:
I am using Crystal Reports in my application I made using Visual Studio.NET. I installed my application on the client machine, with all the DLLs required(added the merge modules), the engine and...
4
by: John R. Dougherty | last post by:
I have developed an application with VB.NET, which includes the Crystal Reports (Visual Studio .NET 2003 edition) controls. I can run the application on my PC and it does work fine, but on any...
3
by: VMI | last post by:
I know this may not be the best NG for this, but I feel you guys know more about this than any of the other NGs. I need to build several simple reports (over 50 of them and they get their data...
5
by: Jay | last post by:
I am getting mixed messages from the asp.net website hosting providers - some say they do not support Crystal Reports due to a $25,000 per cpu licensing fee, others say all I need to do is install...
3
by: ian_jacobsen | last post by:
First let me start by saying that this problem is not consistently reproducible. I have a windows service that creates reports for a group of entities. This service can process multiple groups at...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.