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 3936172
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T23:54:55+00:00 2026-05-19T23:54:55+00:00

I have 30 buttons with nothing in default text value. What i want to

  • 0

I have 30 buttons with nothing in default text value. What i want to do is get the ordered data from database:

Here is the database format:

ID       value                   cat
1       Button name               a
2       Another name              a
3       something                 a
.           .                     a
.           .                     a
.           .                     a
30      Last button               a
1       Button name               b
2       Another name              b
3       something                 b
.           .                     b
.           .                     b
.           .                     b
18      Last button               b

Now i have created a function to grab ID and category to select the specific name using OLEDB for MS ACCESS database.

here is a function:

 private string getItem(int i, string a) {
     //database connection
    // database query and table slection where ID = i and cat = a
    read the data in the selected column
    return the string form of the column
 }

Now whenever a form loads, I’ve assigned following function:

 button1.Show();
      ...
      ...
  button30.Show();
  button1.Text = getItem(1, a);
  button2.Text = getItem(2, a); 
       ..
       ...
       ...
  button30.text = getItem(30, a);

again there is a separate button to change the category that will change the text value in the button:

button1.Text = getItem(1, b);
  button2.Text = getItem(2, b);
       .
       .
       .
  button18.Text = getItem(18, b);
  // because I have only 18 items I hide all the remaining buttons.
  button19.Hide();
           ...
  button30.Hide();

It works well and easy, but the problem is, it is too slow.
Whenever the form loads it takes time to fill all the data to the buttons and also when I click the button to change the category it happens there too.

Is there any method to do this in array or something like that?
The above code requires multiple time access to database resulting slow processing.

Another problem is, if i have only 18 or lesser than 30 items in the database table, the pre made buttons will be visible with default values in it.

In the above code I overcome it by using buttonx.Hide() while x is for all the values that doesn’t have any values..

These all are manual work and required mass codding.

I will be grateful to know some good method to overcome this problem.

  • 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-05-19T23:54:56+00:00Added an answer on May 19, 2026 at 11:54 pm

    There is lot of messy code there so do these things:

    • First dont have all the butttons available all the time (this will solve the problem of having stray buttons with default text). Instead generate and add them on form from you your code (Form.Controls.Add()).

    • Instead of doing multiple roundtrips. have a DataTable in you code to keep a cache of the table and instead Fetch this DataTable. (If the data is too much volatile then this might not be of use, still instead of query for eachitem query whole Table at once)

    • You can use LINQ to query DataTable to reduce code size. (And make it more maintainable)

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

Sidebar

Related Questions

I want to have buttons that kind of act like tabs - they switch
I have some buttons in an UIView. My problem is, that they get cut
I have 3 buttons Docked to left but I want to put them in
I have a UITableViewCell that has 2 UIButton instances. Both buttons have a default
For my mobile-desktop nav-bar I have background buttons (default). On top I'm using :after
I have three button named(titled) hello, nothing, heaven and one label (IBOutlet UIlabel lab).
We have place a button on a view. When we press it, nothing happens.
I have buttons on a page that look like: <p> <a href=view.php> <input type=button
I have buttons and a selector for the buttons, the code looks like this:
Multiple sites have buttons where you can tweet, digg, etc. On this page you'll

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.