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. C#
  4. Passing Parameter in ...

Passing Parameter in ...

Scheduled Pinned Locked Moved C#
csharphelptutorialquestion
8 Posts 2 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.
  • M Offline
    M Offline
    mostafa_h
    wrote on last edited by
    #1

    Could anyone help me how to pass parameter in crystal report using c#.net? I'm new to this.I need a sample code Thanks In Advance REGARDS,

    s_mostafa_h

    C 1 Reply Last reply
    0
    • M mostafa_h

      Could anyone help me how to pass parameter in crystal report using c#.net? I'm new to this.I need a sample code Thanks In Advance REGARDS,

      s_mostafa_h

      C Offline
      C Offline
      CooperWu
      wrote on last edited by
      #2

      our solution: -- create a table in database as crystal report settings.

      M 1 Reply Last reply
      0
      • C CooperWu

        our solution: -- create a table in database as crystal report settings.

        M Offline
        M Offline
        mostafa_h
        wrote on last edited by
        #3

        In Form1 I've a checkbox . I created a parameter in crystal report . this is my code : in btnReport_Click :

        {
        string strQuery = "SELECT Name FROM MyTable";
        sqlconn.Open();
        daAdapter = new SqlDataAdapter(strQuery, sqlconn);
        SqlCommandBuilder scb = new SqlCommandBuilder(daAdapter);
        da.Fill(DatatSet1.MyTable);
        //Definitions
        ParameterField paramfield = new ParameterField();
        ParameterFields paramfields = new ParameterFields();
        ParameterDiscreteValue discreteval = new ParameterDiscreteValue();
        //setting
        paramfield.Name = "Name";
        discreteval.Value = DataSet1.MyTable.Columns[0];
        paramfield.CurrentValues.Add(discreteval);
        paramfields.Add(paramfield);
        crystalReportViewer1.ParameterFieldInfo = paramfields;
        crystalReportViewer1.ReportSource = crystalreport1;
        sqlconn.Close();
        }

        I want to take a report from all of records' Name field of the Table When The user checked "CheckBox1" Control . I have an Error in this part : discreteval.Value = DataSet1.MyTable.Columns[0]; with this message : Value does not fall within the expected range. Please Help Me ! Regrds ,

        s_mostafa_h

        C 1 Reply Last reply
        0
        • M mostafa_h

          In Form1 I've a checkbox . I created a parameter in crystal report . this is my code : in btnReport_Click :

          {
          string strQuery = "SELECT Name FROM MyTable";
          sqlconn.Open();
          daAdapter = new SqlDataAdapter(strQuery, sqlconn);
          SqlCommandBuilder scb = new SqlCommandBuilder(daAdapter);
          da.Fill(DatatSet1.MyTable);
          //Definitions
          ParameterField paramfield = new ParameterField();
          ParameterFields paramfields = new ParameterFields();
          ParameterDiscreteValue discreteval = new ParameterDiscreteValue();
          //setting
          paramfield.Name = "Name";
          discreteval.Value = DataSet1.MyTable.Columns[0];
          paramfield.CurrentValues.Add(discreteval);
          paramfields.Add(paramfield);
          crystalReportViewer1.ParameterFieldInfo = paramfields;
          crystalReportViewer1.ReportSource = crystalreport1;
          sqlconn.Close();
          }

          I want to take a report from all of records' Name field of the Table When The user checked "CheckBox1" Control . I have an Error in this part : discreteval.Value = DataSet1.MyTable.Columns[0]; with this message : Value does not fall within the expected range. Please Help Me ! Regrds ,

          s_mostafa_h

          C Offline
          C Offline
          CooperWu
          wrote on last edited by
          #4

          copy this, and paste in VS Help address box: ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.en/crystlmn/html/crtsktutorialsrdparametersdiscrete.htm this is Tutorial: Reading and Setting Discrete Parameters

          M 1 Reply Last reply
          0
          • C CooperWu

            copy this, and paste in VS Help address box: ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.en/crystlmn/html/crtsktutorialsrdparametersdiscrete.htm this is Tutorial: Reading and Setting Discrete Parameters

            M Offline
            M Offline
            mostafa_h
            wrote on last edited by
            #5

            it didn't help me . in any case , when the user checked the checkbox contrlol , I want to dislpaly all of the specied field record (for e.g. "Name"), How can i do in this section : **discreteval.Value =???** thanks

            s_mostafa_h

            C 1 Reply Last reply
            0
            • M mostafa_h

              it didn't help me . in any case , when the user checked the checkbox contrlol , I want to dislpaly all of the specied field record (for e.g. "Name"), How can i do in this section : **discreteval.Value =???** thanks

              s_mostafa_h

              C Offline
              C Offline
              CooperWu
              wrote on last edited by
              #6

              ParameterDiscreteValue.Value Property Gets or sets the value of the parameter. This can be a string, number, currency, Boolean or date. -- try discreteval.Value = "special_name";

              M 1 Reply Last reply
              0
              • C CooperWu

                ParameterDiscreteValue.Value Property Gets or sets the value of the parameter. This can be a string, number, currency, Boolean or date. -- try discreteval.Value = "special_name";

                M Offline
                M Offline
                mostafa_h
                wrote on last edited by
                #7

                this shows only one record of field that we specified . but I Want to show all record this field column . my field is "Name" in the table . regards,

                s_mostafa_h

                C 1 Reply Last reply
                0
                • M mostafa_h

                  this shows only one record of field that we specified . but I Want to show all record this field column . my field is "Name" in the table . regards,

                  s_mostafa_h

                  C Offline
                  C Offline
                  CooperWu
                  wrote on last edited by
                  #8

                  you can build all names in to a string, like this: name1,name2,name3 then split it in crystal report formula editor? I am not sure which manner you used in crystal report. if you can't split it. I have no idea. may be you need contact crystal report support to solve your problem?

                  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