Posted 26 August 2018, 10:09 am EST
Hi Esha,
Using the example code you provided, I am having no success using a parameter to set the Top Count in the Select portion of the SQL Query. Here is my modified code:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
'Default parameter set at simple button click
Dim para As ReportParameter
C1FlexReport1.DataSource.RecordSource = "select TOP [TopCount] * from [Cars] where [Cyl] = [Cylinder];"
para = New ReportParameter
para.DataType = C1.Win.C1Document.ParameterType.[Integer]
para.Name = "Cylinder"
para.Prompt = "Cylinder"
para.Value = 6
para.AllowedValuesDefinition.Binding.DataSourceName = C1FlexReport1.DataSource.Name
C1FlexReport1.Parameters.Add(para)
para = New ReportParameter
para.DataType = C1.Win.C1Document.ParameterType.[Integer]
para.Name = "TopCount"
para.Prompt = "Top Count"
para.Value = 2
'para.AllowedValuesDefinition.Binding.DataSourceName = C1FlexReport1.DataSource.Name
C1FlexReport1.Parameters.Add(para)
'C1FlexReport1.Render()
C1FlexViewer1.DocumentSource = C1FlexReport1
End Sub
When I run this, it reports that the SELECT statement contains an error. It looks like the parameter is not being substituted into the SQL Query.
Also, I do not understand how the "AllowedValuesDefinition’ works. It does not seem to make any difference how I set it, but is it supposed to derive the allowed values from the datasource itself? I don’t understand how it does this. In the example code, are the allowable values for Cylinders derived from the Cars table? How does it do this?
Thank you for your help.
Charlie