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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Storing values into a 2-Dimensional Array

Storing values into a 2-Dimensional Array

Scheduled Pinned Locked Moved C#
cssdatabasedata-structureshelp
5 Posts 3 Posters 1 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.
  • R Offline
    R Offline
    Reality Strikes
    wrote on last edited by
    #1

    Hello, Here I'm directly passing the crystal reports parameters through the code, and generating the report but for some obvious reason, I want the records to be stored first of all into a 2-dimensional array and from there writing it back onto Crystal reports. Note : The reason why I'm looking for 2-Dimensional array is that currently upon execution I'm getting a Crystal Report with repeated records and that too upto the no. of maximum records in table. To be more clear, lets say, that I have an access database with 30,000 records and whn I generate the crystal report I'm expecting all 30,000 records to be displayed row-by-row. But instead of that I'm getting the first record repeated 30,000 times..........NEED HELP........!!! The actual code before storing it in 2D-array is as given below:

    private void btnReport_Click(object sender, System.EventArgs e)
    { try
    {
    makeReport(report_file);
    for (int recordCount=0; recordCount <= myTable.Rows.Count; recordCount++)
    {
    SetParamValue("@parameter1", myTable.Rows[recordCount]["CLNT#"].ToString));
    SetParamValue("@parameter2", myTable.Rows[recordCount]"CNAME"].ToString));
    SetParamValue("@parameter3", myTable.Rows[recordCount]["CSEX"].ToString));

                SetParamValue("@parameter4", myTable.Rows\[recordCount\]\["CSS#"\].ToString()); 	        crystalReportViewer1.ReportSource = ReportDoc;				
            }
      }	
      catch (Exception ex)	
      {             
            MessageBox.Show(ex.Message, "EXCEPTION");	
      }
    

    }

    private void SetParamValue (string paramName, string paramValue)
    {
    for(int i=0; i<reportdoc.datadefinition.formulafields.count;>
    if(ReportDoc.DataDefinition.FormulaFields[i].FormulaName=="{" + paramName + "}")
    {
    ReportDoc.DataDefinition.FormulaFields[i].Text = "\"" +paramValue +"\"";
    }
    crystalReportViewer1.ReportSource = ReportDoc;
    }

    private void makeReport(string ReportFile)
    {
    ReportDoc.Load(ReportFile); // where ReportFile is the path of report (@"c:/reports/..)
    }

    L P 2 Replies Last reply
    0
    • R Reality Strikes

      Hello, Here I'm directly passing the crystal reports parameters through the code, and generating the report but for some obvious reason, I want the records to be stored first of all into a 2-dimensional array and from there writing it back onto Crystal reports. Note : The reason why I'm looking for 2-Dimensional array is that currently upon execution I'm getting a Crystal Report with repeated records and that too upto the no. of maximum records in table. To be more clear, lets say, that I have an access database with 30,000 records and whn I generate the crystal report I'm expecting all 30,000 records to be displayed row-by-row. But instead of that I'm getting the first record repeated 30,000 times..........NEED HELP........!!! The actual code before storing it in 2D-array is as given below:

      private void btnReport_Click(object sender, System.EventArgs e)
      { try
      {
      makeReport(report_file);
      for (int recordCount=0; recordCount <= myTable.Rows.Count; recordCount++)
      {
      SetParamValue("@parameter1", myTable.Rows[recordCount]["CLNT#"].ToString));
      SetParamValue("@parameter2", myTable.Rows[recordCount]"CNAME"].ToString));
      SetParamValue("@parameter3", myTable.Rows[recordCount]["CSEX"].ToString));

                  SetParamValue("@parameter4", myTable.Rows\[recordCount\]\["CSS#"\].ToString()); 	        crystalReportViewer1.ReportSource = ReportDoc;				
              }
        }	
        catch (Exception ex)	
        {             
              MessageBox.Show(ex.Message, "EXCEPTION");	
        }
      

      }

      private void SetParamValue (string paramName, string paramValue)
      {
      for(int i=0; i<reportdoc.datadefinition.formulafields.count;>
      if(ReportDoc.DataDefinition.FormulaFields[i].FormulaName=="{" + paramName + "}")
      {
      ReportDoc.DataDefinition.FormulaFields[i].Text = "\"" +paramValue +"\"";
      }
      crystalReportViewer1.ReportSource = ReportDoc;
      }

      private void makeReport(string ReportFile)
      {
      ReportDoc.Load(ReportFile); // where ReportFile is the path of report (@"c:/reports/..)
      }

      L Offline
      L Offline
      leppie
      wrote on last edited by
      #2

      Whats the point of setting the same paramvalue over and over?

      xacc.ide - now with TabsToSpaces support
      IronScheme - 1.0 alpha 4a out now (29 May 2008)

      R 1 Reply Last reply
      0
      • L leppie

        Whats the point of setting the same paramvalue over and over?

        xacc.ide - now with TabsToSpaces support
        IronScheme - 1.0 alpha 4a out now (29 May 2008)

        R Offline
        R Offline
        Reality Strikes
        wrote on last edited by
        #3

        In my opinion, they are all different parameter values (i.e @parameter1, 2 and so on) are they are the parameters which are being passed into the Crystal Report under 4 different column headings (i.e Client#, Name, Sex, SSN#).......... to be more clear, @parameter1 wud fetch the value for Client# from the code and pass it to Crystal Report and so on.............since there are 4 fields in Crsyal Reports to be displayed, I have used 4 parameter fields...........did it make any sense............it wud be nice if u can help me with a better way to do this............

        1 Reply Last reply
        0
        • R Reality Strikes

          Hello, Here I'm directly passing the crystal reports parameters through the code, and generating the report but for some obvious reason, I want the records to be stored first of all into a 2-dimensional array and from there writing it back onto Crystal reports. Note : The reason why I'm looking for 2-Dimensional array is that currently upon execution I'm getting a Crystal Report with repeated records and that too upto the no. of maximum records in table. To be more clear, lets say, that I have an access database with 30,000 records and whn I generate the crystal report I'm expecting all 30,000 records to be displayed row-by-row. But instead of that I'm getting the first record repeated 30,000 times..........NEED HELP........!!! The actual code before storing it in 2D-array is as given below:

          private void btnReport_Click(object sender, System.EventArgs e)
          { try
          {
          makeReport(report_file);
          for (int recordCount=0; recordCount <= myTable.Rows.Count; recordCount++)
          {
          SetParamValue("@parameter1", myTable.Rows[recordCount]["CLNT#"].ToString));
          SetParamValue("@parameter2", myTable.Rows[recordCount]"CNAME"].ToString));
          SetParamValue("@parameter3", myTable.Rows[recordCount]["CSEX"].ToString));

                      SetParamValue("@parameter4", myTable.Rows\[recordCount\]\["CSS#"\].ToString()); 	        crystalReportViewer1.ReportSource = ReportDoc;				
                  }
            }	
            catch (Exception ex)	
            {             
                  MessageBox.Show(ex.Message, "EXCEPTION");	
            }
          

          }

          private void SetParamValue (string paramName, string paramValue)
          {
          for(int i=0; i<reportdoc.datadefinition.formulafields.count;>
          if(ReportDoc.DataDefinition.FormulaFields[i].FormulaName=="{" + paramName + "}")
          {
          ReportDoc.DataDefinition.FormulaFields[i].Text = "\"" +paramValue +"\"";
          }
          crystalReportViewer1.ReportSource = ReportDoc;
          }

          private void makeReport(string ReportFile)
          {
          ReportDoc.Load(ReportFile); // where ReportFile is the path of report (@"c:/reports/..)
          }

          P Offline
          P Offline
          Pete OHanlon
          wrote on last edited by
          #4

          reality_strikes wrote:

          crystalReportViewer1.ReportSource = ReportDoc;

          Shouldn't this line be outside your loop? At the moment, it's being called in every iteration.

          Deja View - the feeling that you've seen this post before.

          My blog | My articles

          R 1 Reply Last reply
          0
          • P Pete OHanlon

            reality_strikes wrote:

            crystalReportViewer1.ReportSource = ReportDoc;

            Shouldn't this line be outside your loop? At the moment, it's being called in every iteration.

            Deja View - the feeling that you've seen this post before.

            My blog | My articles

            R Offline
            R Offline
            Reality Strikes
            wrote on last edited by
            #5

            pete, thanks for the reply..........i tried even tht b4..........whn i place that line outside the loop, it displays the first record for some milliseconds and the crystal report screen blinks and then it loads the second record and it goes on till the last record and then finally the last record is displayed on the crystal report screen........still need help.............

            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