Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. How to Generate data on Crystal Report when Datagridview item is selected

How to Generate data on Crystal Report when Datagridview item is selected

Scheduled Pinned Locked Moved Visual Basic
helptutorialquestion
8 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dambod
    wrote on last edited by
    #1

    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?

    D 1 Reply Last reply
    0
    • D Dambod

      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?

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      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...

      D 1 Reply Last reply
      0
      • D Dave Kreskowiak

        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...

        D Offline
        D Offline
        Dambod
        wrote on last edited by
        #3

        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

        D P 2 Replies Last reply
        0
        • D Dambod

          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

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          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...

          P 1 Reply Last reply
          0
          • D Dave Kreskowiak

            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...

            P Offline
            P Offline
            Paramu1973
            wrote on last edited by
            #5

            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.

            D 1 Reply Last reply
            0
            • P Paramu1973

              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.

              D Offline
              D Offline
              Dave Kreskowiak
              wrote on last edited by
              #6

              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...

              1 Reply Last reply
              0
              • D Dambod

                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

                P Offline
                P Offline
                Paramu1973
                wrote on last edited by
                #7

                Check my previous reply. I hope that can helps you !

                D 1 Reply Last reply
                0
                • P Paramu1973

                  Check my previous reply. I hope that can helps you !

                  D Offline
                  D Offline
                  Dambod
                  wrote on last edited by
                  #8

                  solved

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups