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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:36:15+00:00 2026-05-11T22:36:15+00:00

When writing apps with asp.net, which I do more of than vb.net apps, I

  • 0

When writing apps with asp.net, which I do more of than vb.net apps, I have always followed the rule of opening a connection to the server, getting the data, and closing the connection as quickly as possible. This seems like a best practice.

Is it equally important to do this on a client/server vb.net app? For example, if you had multiple forms, each either with a grid of data, or a form of data, would you typically open the connection when each form started, close it when the user left the form? or is it acceptable to define a global variable for the connection and keep it open the entire life span of the app?

Personally I would tend to open/close the connection with each form, but wondering what other folks recommend with a typical desktop c/s app?

  • 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-11T22:36:15+00:00Added an answer on May 11, 2026 at 10:36 pm

    Only use it when you need it. Don’t keep things lying around if you’re not going to need it and use it right away. Same principle of declaring your variables and using them soon, rather than, say, having an enormous list of declarations near the top and using them later – this is confusing and can leave things unused unnecessarily.

    Also, if you stick with the using statement pattern whenever you’re using your SQL connection then it will do the closing for you. This is better than having it scattered and potentially forgetting to close it – depending on load this could tie up your connections and eventually lead to some connections being refused. I’m not saying you’re not already doing this, but just in case. Most MSDN examples will show the using pattern for classes that implement IDisposable.

    More on using here. The SqlConnection example shows the same thing. The using statement has the added benefit of acting like a try/finally block.

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

Sidebar

Related Questions

I've been writing asp.net apps with SQL Server back ends for the past 10
ASP.NET apps that I've developed (on ASP.NET 2.0) have typically been backed by a
I prefer to use jQuery with my ASP.NET MVC apps than the Microsoft Ajax
We're writing Windows desktop apps using C++ and Win32. Our dialog boxes have an
I am writing a couple of django apps which by design are coupled together.
I am writing an app which - similarly to many apps out there -
I am writing a simple framework for testing WinForm apps, which is running in
So I'm writing a framework on which I want to base a few apps
This is a general question about writing web apps. I have an application that
(I'm Coming from a C# background writing iPhone apps with MonoTouch) I have a

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.