473,320 Members | 2,145 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,320 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 2338
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.