Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

New User - Crystal Reports and ASP

Status
Not open for further replies.

dom24

Programmer
Aug 5, 2004
218
GB
HI,

I've never used Crystal Reports before and i'm trying to find out if it would be the most effective way of creating reports online using a backend sql database.
I have already completed the database and frontend system to populate the database, but i'm now trying to create a frontend that enables admin staff to click buttons and create a report based on the data in the database.
Any help would be appreciated.

Thanks.
 
Hi,
I created a frontend web form that captures the criteria needed for the report, then sets some session variables to carry them into the ASPX page. In the load event of the ASPX page, I then use the FormLoad event to retrieve only those records required via a dataset.

Please let me know if you want a copy of the code used to do this.

HTH, [pc2]
Randy Smith, MCP
California Teachers Association
 
synapsevampire- that link doesn't work.

randysmid - Yes please that would be really helpful if you could send me the code. Just one question, what do you mean by ASPX? Is that to do with ASP.Net? If so i'm usign ASP not .Net so it might not work with mine?
 
Yeah it's working ok now. Must just have been down earlier.
 
Hi Dom,
Yes, ASPX pages are for .Net, but I think this code will work with ASP. The idea behind this is to "push-down" the record selection to the database server. In my case, this was critical because one of my tables has 1.5 million rows. Here are the steps I am using:

1) Create a web form where the user can enter the parameters. On this form, you will need a command button to set the session variables and then call the next web form that contains the Crystal Report Viewer. You can create a session variable (e.g., "CTARegion") with any name like this:
Session("CTARegion") = txtRegion.Text

2) Create the report using the fields needed from the various table(s).

3) Create the web form that will hold the Crystal Report Viewer. In the page load event, I placed the following code:
If Not Page.IsPostBack Then
'Retrieve parameter value entered in web form
' CountySelectRegion.aspx

Dim strRegion As String
strRegion = Session("CTARegion".ToString)

' connect to Access database
Dim sConnString As String = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" + MapPath("CDR2004.MDB") & ";" & _
"User ID=Admin;" & _
"Password="

Dim oOleDbConnection As OleDb.OleDbConnection = New OleDbConnection(sConnString)
oOleDbConnection.Open()

' build the select statement
Dim selectString As String = "select * from COUNTY where CTA_RegionID = '" & strRegion & "'"

Dim tempOleDbDataAdapter As New OleDbDataAdapter(selectString, oOleDbConnection)

Dim dsCountyRegion As New DataSet

tempOleDbDataAdapter.Fill(dsCountyRegion, "County")

Dim cr As CountyRegionRpt
cr = New CountyRegionRpt

cr.SetDataSource(dsCountyRegion)
CrystalReportViewer1.ReportSource = cr

End If


4) Normally, the Crystal Report Viewer is bound to the report (through Bindings), but in this instance you should not do this.




HTH, [pc2]
Randy Smith, MCP
California Teachers Association
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top