Click here to Skip to main content
15,844,387 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB
'This is my select query
Dim rpt As New rptItems()
Dim myConnection As OleDbConnection
Dim MyCommand As New OleDbCommand()
Dim myDA As New OleDbDataAdapter()
Dim myDS As New DataSet 'The DataSet you created.
myConnection = New OleDbConnection(cnn)
MyCommand.Connection = myConnection
MyCommand.CommandText = "SELECT ItemCode, ItemName,Qty FROM ItemTable"
MyCommand.CommandType = CommandType.Text
myDA.SelectCommand = MyCommand

myDA.Fill(myDS, "Dataset1")

rpt.SetDataSource(myDS)
Report.CrystalReportViewer1.ReportSource = rpt
Report.Show()

'**********************************************************************************
'This is my parameter fields.
Dim rpt As New rptItems()
Dim crParameterFieldDefinitions As ParameterFieldDefinitions
Dim crParameterFieldDefinition As ParameterFieldDefinition
Dim crParameterValues As New ParameterValues
Dim crParameterDiscreteValue As New ParameterDiscreteValue

crParameterDiscreteValue.Value = TextBox1.Text
crParameterFieldDefinitions = rpt.DataDefinition.ParameterFields
crParameterFieldDefinition = crParameterFieldDefinitions.Item("Customername")
crParameterValues = crParameterFieldDefinition.CurrentValues

crParameterValues.Clear()
crParameterValues.Add(crParameterDiscreteValue)
crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)

Report.CrystalReportViewer1.ReportSource = rpt
Report.CrystalReportViewer1.Refresh()
Report.Show()
Posted
Comments
KaushalJB 6-Jul-15 5:14am    
So what is the issue ?
Member 10595674 6-Jul-15 8:43am    
sorry it doesn't work. can I populate Crystal Report with dataset and pass parameter value into a Crystal Report in the same statement.
KaushalJB 7-Jul-15 1:29am    
Yes you can. Perform Report.Show() only once.
Member 10595674 7-Jul-15 2:30am    
Ok thank you much.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900