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)