How to Generate data on Crystal Report when Datagridview item is selected
-
hi there, i am using crystal report 10 to generate using VB 2008. I have a problem in generating data for crystal report when datagridview item is selected. my datagridview gets data from a dataset called ds. any help?
You haven't provided enough information to tell you anything useful. What's the problem you're having? What are the error messages, if any?? What does the code look like where the error was generated?? What does selecting an item in the DGV have to do with generating the report?? ...
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008
But no longer in 2009... -
You haven't provided enough information to tell you anything useful. What's the problem you're having? What are the error messages, if any?? What does the code look like where the error was generated?? What does selecting an item in the DGV have to do with generating the report?? ...
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008
But no longer in 2009...For i As Integer = 0 To DataGridView1.Rows.GetRowCount(DataGridViewElementStates.None) - 1 If DataGridView1(2, i).Value Is DBNull.Value Then MsgBox("you didn't Select Student ID", MsgBoxStyle.Exclamation, "Student ID Missing") Else 'displaying selected student data on crystal report If DataGridView1(3, i).Value.ToString = "A" Then rpt.setdatasource(ds) 'ds is my dataset where student table is found dim myparams as new new ParameterFields() dim myparam as ParameterField = new ParameterField() dim myDiscretevalue as new ParameterDiscreteValue() '// Set the ParameterFieldName to the name of the parameter '// created in the Field Explorer myParam.ParameterFieldName = "StudFullName '// Add first student myDiscreteValue.Value = "Peter" myParam.CurrentValues.Add(myDiscreteValue) '// Reuse myDiscreteValue, and assign second student myDiscreteValue = new ParameterDiscreteValue() myDiscreteValue.Value = "Smith" myParam.CurrentValues.Add(myDiscreteValue); '// Add param object to params collection myParams.Add(myParam) '// Assign the params collection to the report viewer myCrystalReportViewer.ParameterFieldInfo = myParams '// Assign the Report to the report viewer. '// This method uses a strongly typed report, '// but other methods are possible as well. myCrystalReportViewer.ReportSource = MyReportObject end if and the problem is it says no valid table. can u help me in correcting this code so that when datagridview row is selected, data for the selected student is displayed on the report thanks
-
For i As Integer = 0 To DataGridView1.Rows.GetRowCount(DataGridViewElementStates.None) - 1 If DataGridView1(2, i).Value Is DBNull.Value Then MsgBox("you didn't Select Student ID", MsgBoxStyle.Exclamation, "Student ID Missing") Else 'displaying selected student data on crystal report If DataGridView1(3, i).Value.ToString = "A" Then rpt.setdatasource(ds) 'ds is my dataset where student table is found dim myparams as new new ParameterFields() dim myparam as ParameterField = new ParameterField() dim myDiscretevalue as new ParameterDiscreteValue() '// Set the ParameterFieldName to the name of the parameter '// created in the Field Explorer myParam.ParameterFieldName = "StudFullName '// Add first student myDiscreteValue.Value = "Peter" myParam.CurrentValues.Add(myDiscreteValue) '// Reuse myDiscreteValue, and assign second student myDiscreteValue = new ParameterDiscreteValue() myDiscreteValue.Value = "Smith" myParam.CurrentValues.Add(myDiscreteValue); '// Add param object to params collection myParams.Add(myParam) '// Assign the params collection to the report viewer myCrystalReportViewer.ParameterFieldInfo = myParams '// Assign the Report to the report viewer. '// This method uses a strongly typed report, '// but other methods are possible as well. myCrystalReportViewer.ReportSource = MyReportObject end if and the problem is it says no valid table. can u help me in correcting this code so that when datagridview row is selected, data for the selected student is displayed on the report thanks
You haven't said which line the error throws on. I also don't use CrystalReports, so I don't know how much help I'm going to be.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008
But no longer in 2009... -
You haven't said which line the error throws on. I also don't use CrystalReports, so I don't know how much help I'm going to be.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008
But no longer in 2009...1.With your application you have to create one Dataset-[XSD] file, and create a datatable there and the crystal reports field has to be from xsd. 2.After from a button click(), display thru a crystalreportviewer, but the data from datagridview selected row has to send to dataset which one you have already created from form ds. Dim ObjRpt As New CrystalReport1 ObjRpt.SetDataSource(DS62.Tables(0)) CrystalReportViewer1.ReportSource = ObjRpt CrystalReportViewer1.Refresh() CrystalReportViewer1.Visible = True From the above, DS62 is the dataset in form. My xsd filename is Dataset1 and Datatable is Datatable1.
-
1.With your application you have to create one Dataset-[XSD] file, and create a datatable there and the crystal reports field has to be from xsd. 2.After from a button click(), display thru a crystalreportviewer, but the data from datagridview selected row has to send to dataset which one you have already created from form ds. Dim ObjRpt As New CrystalReport1 ObjRpt.SetDataSource(DS62.Tables(0)) CrystalReportViewer1.ReportSource = ObjRpt CrystalReportViewer1.Refresh() CrystalReportViewer1.Visible = True From the above, DS62 is the dataset in form. My xsd filename is Dataset1 and Datatable is Datatable1.
Reply to the original poster, not me. I just got the notification that you replied. The OP didn't.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008
But no longer in 2009... -
For i As Integer = 0 To DataGridView1.Rows.GetRowCount(DataGridViewElementStates.None) - 1 If DataGridView1(2, i).Value Is DBNull.Value Then MsgBox("you didn't Select Student ID", MsgBoxStyle.Exclamation, "Student ID Missing") Else 'displaying selected student data on crystal report If DataGridView1(3, i).Value.ToString = "A" Then rpt.setdatasource(ds) 'ds is my dataset where student table is found dim myparams as new new ParameterFields() dim myparam as ParameterField = new ParameterField() dim myDiscretevalue as new ParameterDiscreteValue() '// Set the ParameterFieldName to the name of the parameter '// created in the Field Explorer myParam.ParameterFieldName = "StudFullName '// Add first student myDiscreteValue.Value = "Peter" myParam.CurrentValues.Add(myDiscreteValue) '// Reuse myDiscreteValue, and assign second student myDiscreteValue = new ParameterDiscreteValue() myDiscreteValue.Value = "Smith" myParam.CurrentValues.Add(myDiscreteValue); '// Add param object to params collection myParams.Add(myParam) '// Assign the params collection to the report viewer myCrystalReportViewer.ParameterFieldInfo = myParams '// Assign the Report to the report viewer. '// This method uses a strongly typed report, '// but other methods are possible as well. myCrystalReportViewer.ReportSource = MyReportObject end if and the problem is it says no valid table. can u help me in correcting this code so that when datagridview row is selected, data for the selected student is displayed on the report thanks
Check my previous reply. I hope that can helps you !
-
Check my previous reply. I hope that can helps you !