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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:31:02+00:00 2026-05-16T14:31:02+00:00

How do you make SMO release it’s connections? I have this code: public static

  • 0

How do you make SMO release it’s connections?

I have this code:

public static class SqlServerConnectionFactory
{
    public static Server GetSmoServer()
    {
        using (var c = new SqlConnection(ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString))
        {
            var s = new ServerConnection(c);
            c.Close();
            return new Server(s);
        }
    }

    public static Database GetSmoDatabase(Server server)
    {
        var db = server.Databases[ConfigurationManager.AppSettings["Database"]];
        db.AutoClose = true;
        return db;
    }
}

Called like this from an ASP.Net MVC app run in IIS…:

public ActionResult Index()
    {
        server = SqlServerConnectionFactory.GetSmoServer();
        database = SqlServerConnectionFactory.GetSmoDatabase(server);
        var vm = new SettingsIndexViewmodel(database);
        return View(vm);
    }

For every call I make to this index method a connection is spun up – and is not released again.

So after 20 calls to the page, I have 20 of the connections awaiting command. This eventually ends up with an exception, when I cannot make new connections, because the connection pool is full.

sp_who

What do I need to avoid this happening? I cannot seem to find a method on the SMO Server object like Dispose, close or similar.

  • 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-16T14:31:02+00:00Added an answer on May 16, 2026 at 2:31 pm

    The MSDN article Disconnecting from an Instance of SQL Server might offer some help. It states that:

    When the Connect method is called, the
    connection is not automatically
    released. The Disconnect method must
    be called explicitly to release the
    connection to the connection pool.
    Also, you can request a non-pooled
    connection. You do this by setting the
    NonPooledConnection property of the
    ConnectionContext property that
    references the ServerConnection object

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

Sidebar

Related Questions

i make one class file for jar. and this class have use wurfl. and
I make navigation with pages but this code not work, what's the problem ?
I am using this code for backup database from .mdf file. Backup databaseBackup =
I make a interface class in C++ for voice recognition, i´m using the Julius
I make this simple MySQL query using ActiveRecord::Base sql = SELECT * FROM schedules
To make this example as simple as possible, let's say I have the following
I make an app that have to printing image. I need to print image
I make a class level method for Alert: @interface TestAlert @end + (void)showErrorAlert:(NSTimer *)message
I have an application that uses the SQL Management Objects (Microsoft.SqlServer.Smo.dll) and in order
I make some script, that have modal window on fancybox and on load it's

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.