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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:51:32+00:00 2026-05-23T11:51:32+00:00

im creating a webapplication which connects to a database and uses a ODBC connector

  • 0

im creating a webapplication which connects to a database and uses a ODBC connector im using the following code to do this

private void SetupConnection()
{
    conn.ConnectionString = 
        ConfigurationManager.ConnectionStrings["live"].ConnectionString;

    OdbcDataAdapter da = 
        new OdbcDataAdapter("SELECT * FROM MTD_FIGURE_VIEW1 '", conn);

    da.Fill(ds);
}

i want to create a try catch statement which will keep on trying to connect to the database.

psudocode will be try above function, if cant connect try again if it does connect without any errors carry on.

can someone please help me on this

Question relevant update from the comments:

i just want it to keep on trying the
reason for this is the web application
im making will never switch of its
constantly refreshing data, but the
database is switched of fro two hours
every night for backup during this
period i want the app to keep on
trying to connect

  • 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-23T11:51:32+00:00Added an answer on May 23, 2026 at 11:51 am
    private void SetupConnection()
    {
        conn.ConnectionString = 
            ConfigurationManager.ConnectionStrings["ZenLive"].ConnectionString;
    
        bool success = false;
    
        while(!success)
        {
            try
            {
                OdbcDataAdapter da = 
                   new OdbcDataAdapter("SELECT * FROM MTD_FIGURE_VIEW1 '", conn);
    
                da.Fill(ds);
                success = true;
            }
            catch(Exception e)
            {
                Log(e);
                Thread.Sleep(_retryPeriod)
            }
        }
    }
    

    Note as people have commented, this is really not a good idea. You need some way to distinguish between an “expected” exception where the database is turned off and you want to keep retrying, and the case that something unexpected has happened and you don’t want to keep trying.

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

Sidebar

Related Questions

I'm creating a web application using asp.net & WCF as 3 tier architecture, which
I'm creating a web application which loads tabs using AJAX. My problem is that
I have an ASP .NET web application which uses Forms Authentication. Let's call this
I am creating a web application based on data using javascript. This data is
For a web application, when creating the user which will connect to the MySQL
I am creating a web application which has a few management screens, where a
I am creating a web application framework, in which I am providing support for
I am creating a web application using zend, here I create an interface from
I am creating a web application that is accessing a SQLite database in the
I've got an ASP.Net application which manages the IIS server as follows: Successfully using

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.