Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8968341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:26:27+00:00 2026-06-15T17:26:27+00:00

So I have a function that retrieves data from a database, and outputs it.

  • 0

So I have a function that retrieves data from a database, and outputs it. It’s encased in a try block, so that the error from running out of rows to process is dealt with.

Here’s the function that is called on load (to make the initial output), and called later on to update the log box.

Problem is, whenever I call the function again, it outputs the data twice. Since only the data is in the try block, and not the headers, this points to the try / catch being the issue.

Apologies for the messy / hacky code:

    private void NavigateRecords()
    {
        da.Fill(ds1, "LogOutput");
        textlog4.Text = "Date \t\t Time \t\t Floor\r\n";
        try
        {
            for (int i = 0; i <= 20; i++)
            {
                DataRow dRow = ds1.Tables["LogOutput"].Rows[i];
                for (int i2 = 1; i2 <= 3; i2++)
                {
                    textlog4.Text += dRow.ItemArray.GetValue(i2).ToString() + "\t\t";
                }
                textlog4.Text += "\r\n";

            }
        }
        catch { textlog4.Text += "----------------------"; }  
    }

This is the code that does part of the connecting, and may be of use:

        string sql = "SELECT * From tblLog";
        da = new System.Data.SqlClient.SqlDataAdapter(sql, con);
        NavigateRecords();

Initial output:

Date         Time        Floor
6/12        18:18:22        1       
----------------------

Output next time it is called:

Date         Time        Floor
6/12        18:18:22        1       
6/12        18:46:19        2       
6/12        18:18:22        1       
6/12        18:46:19        2       
----------------------
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T17:26:27+00:00Added an answer on June 15, 2026 at 5:26 pm

    its not an issue with your try catch , its an issue with your variables. Clear out the variable before you add the new data to it. I do not see your variable declared in the scope of the method so it retains the data you original put in it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a function that retrieves some data from the database, formats it as
I have a function that retrieves data from a Mysql database, stores the values
I have a database function that retrieves data and then populates a jtable. I
I have the following function that retrieves an image from a twitter feed, the
I have a Jquery Function that basically retrieves a list of users from the
I have create a simple grid that retrieves data from a server through php.
I am making a php page that retrieves data from a database table and
I have retrieved data from local database while typing in textbox using keydown function
I have a wave file, i have a function that retrieves 2 samples per
In my Java code I have function that gets file from the client in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.