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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:27:16+00:00 2026-06-04T21:27:16+00:00

I need to loop through all my databases in a TreeView, then choose TreeNode

  • 0

I need to loop through all my databases in a TreeView, then choose TreeNode for the database name to restore. My code works fine if I choose only 1, 2 or 3 databases to restore. But if I choose many databases it will get hung.

Please check my code and help me..

            foreach (TreeNode tn in trvList.Nodes)
            {
                if (tn.Checked == true)
                { 
                        strFileName = GetFileTorestor(strRealdb);//Check File Directory to restore example : C:data\tn.text.
                        if (strFileName != "")
                        {
                            RestoreDatabase(res, tn);
                        }
                        else
                        {
                            strErorLog += "\r\n -" + tn.Text;
                            blIsEror = true;
                            MessageBox.Show("Database " + tn.Text + " has not found!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }                                 
                }
            }       


    /// <summary>
    /// Restore database according to treenode selected.
    /// </summary>
    /// <param name="res"></param>
    /// <param name="tn"></param>
    private void RestoreDatabase(Restore res,TreeNode tn)
    {
        res.Database = tn.Text;
        res.Action = RestoreActionType.Database;
        res.Devices.AddDevice(strFileName, DeviceType.File);
        res.ReplaceDatabase = true;
        this.pgrRestore.Value = 0;
        this.pgrRestore.Maximum = 100;
        //res.Complete += new ServerMessageEventHandler(sqlRestore_Complete);
        res.PercentCompleteNotification = 5;
        res.PercentComplete += new PercentCompleteEventHandler(sqlRestore_PercentComplete);
        res.SqlRestore(DBHelper.Server);
        stLog += "\r\n " + tn.Text + " from file " + strFileName;//Record database name already restore to log text
        txtLog.Text = stLog;
        txtLog.Refresh();
    }
  • 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-04T21:27:19+00:00Added an answer on June 4, 2026 at 9:27 pm

    If you mean by stuck that the UI freezes for a while then that is because you are excuting your work on the main thread which is the UI thread. No UI interaction is possible as the thread is busy doing your work. You should have a look at BackgroundWorker to perform your work in the background and report progress to the UI.

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

Sidebar

Related Questions

I need to loop through all table elements, somewhere keeping an index and then
I need to write some code that would loop though all rows of a
i have the following code ..i need to loop through end of the file
I need to periodically loop through links in my PHP database to check whether
I use an MS Access database. In the code below, I loop through a
My controller is passing through a list which I then need to loop through
I need to loop through a set of 2-dimensional array of hidden input fields
I need to loop through each day of the week (monday tues...) and compare
Okay so this is a bit complex but I need to loop through this
my heading kinda explains the problem. I need to loop through multiple ul tags

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.