Post Author: davebhoy
CA Forum: Crystal Reports
Hi there
Firstly, a Newbie here!
I'm using crystal for VS2005 and I have a problem using a parameter on my web form. I use a parameter for my report which is a selected value from a dropdown box on the web page. The problem is that my code is not picking up the value and I'm getting no data. It worked fine when I used ADO tables and logoninfo but when I changed it the datasource to a dataset it doesn't work!
The dropdownlist is bound by code on the page load event and I notice that if I manually insert an item it will work when this item is selected but not when any of the actual table values are selected, weird!
Here's the code:
'Set the connection info and create the Dataset Dim ConnStr As String = System.Configuration.ConfigurationManager.ConnectionStrings("ConnStr").ConnectionString Dim objconn As Data.OleDb.OleDbConnection = New Data.OleDb.OleDbConnection(ConnStr) Dim strSQL As String = "SELECT * FROM [" & qrysource & "]" Dim objDA As New OleDb.OleDbDataAdapter(strSQL, ConnStr) Dim objDS As New Data.DataSet objDA.Fill(objDS, "reportDS") ReportDoc.SetDataSource(objDS.Tables(0))
'Declare the parameter fields Dim crParFieldDefs As ParameterFieldDefinitions Dim crParFieldDef As ParameterFieldDefinition Dim crParameterValues As New ParameterValues Dim crParameterDiscreteValue As New ParameterDiscreteValue
'Declare and add the parameter - Director crParFieldDefs = ReportDoc.DataDefinition.ParameterFields crParFieldDef = crParFieldDefs.Item("dtor") crParameterValues = crParFieldDef.CurrentValues crParameterDiscreteValue.Value = ddlDtor.SelectedValue crParameterValues.Add(crParameterDiscreteValue) crParFieldDef.ApplyCurrentValues(crParameterValues)
Any suggestions are very very welcome! Thanks in advance!
Dave