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. Unable to create a 2-Dimensional Array for Database Records...............

Unable to create a 2-Dimensional Array for Database Records...............

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

    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. 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; i++)
    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/..)
    }

    Note : The reason why I'm looking for 2D 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, I'm getting the first record printed 30,000 times. NEED HELP........!!!

    L 1 Reply Last reply
    0
    • R Reality Strikes

      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. 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; i++)
      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/..)
      }

      Note : The reason why I'm looking for 2D 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, I'm getting the first record printed 30,000 times. NEED HELP........!!!

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      reality_strikes wrote:

      To be more clear, I'm getting the first record printed 30,000 times.

      What? That's your problem and your question is how to do something with a 2D array? I don't get it? :confused:

      led mike

      R 2 Replies Last reply
      0
      • L led mike

        reality_strikes wrote:

        To be more clear, I'm getting the first record printed 30,000 times.

        What? That's your problem and your question is how to do something with a 2D array? I don't get it? :confused:

        led mike

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

        led, wht is it tht u didnt understood in this..............i'm struck @ something and need help to move forward.......

        1 Reply Last reply
        0
        • L led mike

          reality_strikes wrote:

          To be more clear, I'm getting the first record printed 30,000 times.

          What? That's your problem and your question is how to do something with a 2D array? I don't get it? :confused:

          led mike

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

          ok, let me make it more clear.........lets say, i have an access database with 100 records and whn i generate the crystal report i'm expecting all 100 records to be displayed row-by-row. Instead I'm getting the first record repeated 100 times.........u shud have got it by now........

          L 1 Reply Last reply
          0
          • R Reality Strikes

            ok, let me make it more clear.........lets say, i have an access database with 100 records and whn i generate the crystal report i'm expecting all 100 records to be displayed row-by-row. Instead I'm getting the first record repeated 100 times.........u shud have got it by now........

            L Offline
            L Offline
            led mike
            wrote on last edited by
            #5

            ROTFLMA Thanks dude, that's the first good laugh I've had today. See what I am thinking is that they didn't design Crystal reports to print out the first row of your table 30,000 times so it's likely your code is incorrect somewhere. Hey check this out man. I've never used Crystal Reports but I bet the following portions of your code just aren't correct because there is no need to assign the .ReportSource property for every single row and for every single parameter in your table. It also doesn't make sense that you have to set report parameters for every single row in your table. What do you think? Are you using some tutorial or something or are you just guessing how to use Crystal Reports?

            reality_strikes wrote:

            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; i++) if(ReportDoc.DataDefinition.FormulaFields[i].FormulaName=="{" + paramName + "}") { ReportDoc.DataDefinition.FormulaFields[i].Text = "\"" +paramValue +"\""; } crystalReportViewer1.ReportSource = ReportDoc; }

            led mike

            R 1 Reply Last reply
            0
            • L led mike

              ROTFLMA Thanks dude, that's the first good laugh I've had today. See what I am thinking is that they didn't design Crystal reports to print out the first row of your table 30,000 times so it's likely your code is incorrect somewhere. Hey check this out man. I've never used Crystal Reports but I bet the following portions of your code just aren't correct because there is no need to assign the .ReportSource property for every single row and for every single parameter in your table. It also doesn't make sense that you have to set report parameters for every single row in your table. What do you think? Are you using some tutorial or something or are you just guessing how to use Crystal Reports?

              reality_strikes wrote:

              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; i++) if(ReportDoc.DataDefinition.FormulaFields[i].FormulaName=="{" + paramName + "}") { ReportDoc.DataDefinition.FormulaFields[i].Text = "\"" +paramValue +"\""; } crystalReportViewer1.ReportSource = ReportDoc; }

              led mike

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

              led, thanks for the reply. But now i'm facing a rather strange problem............when i replace my code with the changes u made in it.........this is what i'm getting : I'm getting the first row repeated 30,000 times then the crystal report screen blinks and loads the 2nd line of record from database and displays it 30,000 times and it goes on like the same until it displays all the 30,000 records the same way. now do u have any clue...........i have tried all this earlier itself..........awaiting reply........

              L 1 Reply Last reply
              0
              • R Reality Strikes

                led, thanks for the reply. But now i'm facing a rather strange problem............when i replace my code with the changes u made in it.........this is what i'm getting : I'm getting the first row repeated 30,000 times then the crystal report screen blinks and loads the 2nd line of record from database and displays it 30,000 times and it goes on like the same until it displays all the 30,000 records the same way. now do u have any clue...........i have tried all this earlier itself..........awaiting reply........

                L Offline
                L Offline
                led mike
                wrote on last edited by
                #7

                reality_strikes wrote:

                when i replace my code with the changes u made in it

                I don't know what to say, i did not make any changes to the code, i simply highlighted the parts that I thought were likely to be wrong.

                led mike

                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