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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"Push down" record selection to the database server

Access 2000

"Push down" record selection to the database server

by  randysmid  Posted    (Edited  )
Hi ALL,
This FAQ is designed to show how 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. I am using this with ASP.Net and CR10, but I believe the technique will work in most instances. 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.


Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top