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. need help with LOOP to display records from Access Database............

need help with LOOP to display records from Access Database............

Scheduled Pinned Locked Moved C#
helpcssdatabase
4 Posts 2 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

    At the button click event, it displays records, but the problem here is that instead of showing all the 30,000 records, its displaying only the first row of record and that too upto the no. of total records which is close to 30,000 ( i.e First row of record is being repeated 30,000 times ). I tried using loops, but it hangs somewhere.........i'm wrong somewhere........i need help........the code is shown below........

    myTable.rows.count ]fecthes the correct 30,000 records count

    OleDbConnection myCon = new OleDbConnection();
    OleDbDataAdapter myAdp = new OleDbDataAdapter();
    DataViewManager myDvMngr = new DataViewManager();
    DataSet myDS = new DataSet();
    DataTable myTable = new DataTable();
    string report_file = "";
    ReportDocument ReportDoc = new ReportDocument();

    private void btnReport_Click(object sender, System.EventArgs e)
    {
    makeReport(report_file);
    {
    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;
    }

    P R 2 Replies Last reply
    0
    • R Reality Strikes

      At the button click event, it displays records, but the problem here is that instead of showing all the 30,000 records, its displaying only the first row of record and that too upto the no. of total records which is close to 30,000 ( i.e First row of record is being repeated 30,000 times ). I tried using loops, but it hangs somewhere.........i'm wrong somewhere........i need help........the code is shown below........

      myTable.rows.count ]fecthes the correct 30,000 records count

      OleDbConnection myCon = new OleDbConnection();
      OleDbDataAdapter myAdp = new OleDbDataAdapter();
      DataViewManager myDvMngr = new DataViewManager();
      DataSet myDS = new DataSet();
      DataTable myTable = new DataTable();
      string report_file = "";
      ReportDocument ReportDoc = new ReportDocument();

      private void btnReport_Click(object sender, System.EventArgs e)
      {
      makeReport(report_file);
      {
      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;
      }

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

      You seem to be missing the loop, but you may want to try something like:

      foreach (DataRow row in myTable.Rows)
      {
      SetParamValue("@...", row["CLNT#"].ToString();
      ... and so on.
      }

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

      My blog | My articles

      R 1 Reply Last reply
      0
      • R Reality Strikes

        At the button click event, it displays records, but the problem here is that instead of showing all the 30,000 records, its displaying only the first row of record and that too upto the no. of total records which is close to 30,000 ( i.e First row of record is being repeated 30,000 times ). I tried using loops, but it hangs somewhere.........i'm wrong somewhere........i need help........the code is shown below........

        myTable.rows.count ]fecthes the correct 30,000 records count

        OleDbConnection myCon = new OleDbConnection();
        OleDbDataAdapter myAdp = new OleDbDataAdapter();
        DataViewManager myDvMngr = new DataViewManager();
        DataSet myDS = new DataSet();
        DataTable myTable = new DataTable();
        string report_file = "";
        ReportDocument ReportDoc = new ReportDocument();

        private void btnReport_Click(object sender, System.EventArgs e)
        {
        makeReport(report_file);
        {
        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;
        }

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

        thanks for the reply........i'm already using the SetParamValue() as shown below:

        private void makeReport(string ReportFile)
        {
        ReportDoc.Load(ReportFile);
        }

        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 +"\"";
        }
        }
        }

        1 Reply Last reply
        0
        • P Pete OHanlon

          You seem to be missing the loop, but you may want to try something like:

          foreach (DataRow row in myTable.Rows)
          {
          SetParamValue("@...", row["CLNT#"].ToString();
          ... and so on.
          }

          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
          #4

          Is anyone out there to help me out...........i tried using the DataRow as well, i'm getting weird results: 1. The first record is repeated 30,000 times and the report shows no other records. 2. After some code changes, the Crytal Reports again shows one record for 30,000 times and then the Crystal Reports screeb blinks and it displays the second record and displays it 30,000 times and so on until I close the program........ Please help me friends.........

          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