locked
Prevent automatic dispose() with database helper RRS feed

  • Question

  • User-1669978483 posted

    Hello. Is there any way to prevent database dispose() from getting called automatically at the end of page execution when using the ASP.NET Web Pages database helper?

    I'm testing some benchmarks using a single App.Conn connection to prevent multiple simultaneous connections to an OLEDB database.

    However every time I open a query such as App.Conn.Query(SQL) it automatically disposes the database connection. Thank you very much for any information.

    Mike

    Monday, February 23, 2015 12:17 PM

Answers

  • User-821857111 posted

    Is there any way to prevent database dispose() from getting called automatically at the end of page execution when using the ASP.NET Web Pages database helper?

    The Web Pages framework is designed to work that way. There is no configuration setting to prevent this, so your choices are either not to use the Database helper, or not to use Web Pages.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, February 26, 2015 4:03 AM

All replies

  • User-760709272 posted

    You'd need to have a very good reason to not want simultaneous connections to your database.  If your db can't handle multiple connections it was never designed to work from a website and under heavy load your entire website will stop functioning.

    ADO does pooling etc under the covers that you won't be able to control.  If you want single access then I'd use something like a static class with locking and have your code access the db via that class's methods.  That way you can ensure there is only one process accessing the db at a time.

    Monday, February 23, 2015 12:31 PM
  • User-821857111 posted

    Is there any way to prevent database dispose() from getting called automatically at the end of page execution when using the ASP.NET Web Pages database helper?

    The Web Pages framework is designed to work that way. There is no configuration setting to prevent this, so your choices are either not to use the Database helper, or not to use Web Pages.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, February 26, 2015 4:03 AM