I am creating a MS Windows service, which listens for TCP connections. When connected, it gets data from a SQL db and returns it via the TCP socket. What are the drawbacks, if any, of opening a SqlConnection to the SQL Server at service start time, and just re-using that, until it might fail, as opposed to opening a new connection each time a "request" is made? I expect a small number of instantiations of the service functionality - less than 10 a day, but it could be more than that.
Are there drawbacks to leaving a SqlConnection open long-term?
144 views Asked by Conrad At
1
There are 1 answers
Related Questions in WINDOWS
- how to play a sounds in c# forms?
- Echo behaviour of Microsoft Windows Telnet Client
- Getting error while running spark-shell on my system; pyspark is running fine
- DirectX 9 With No SDK Installed - How To Translate a D3DMATRIX?
- Gradle 8.7 cannot find installed JDK 22 in IntelliJ
- 'IOException: The cloud file provider is not running', when trying to delete 'cloud' folder
- Cannot load modules/mod_dav_svn.so into server
- Issue with launching application after updating ElectronJs to version 28.0.0 on Windows and Linux
- 32-bit applications do not display some files in Windows 10
- 'bun' is not recognized as an internal or external command
- mkssecreenshotmgr taking a screenshot
- Next js installation in windows 7 os
- Can't resize a partition using Mini Tool?
- Is there any way to set a printer as default according with Active Directory Policy Security Group and PC hostname?
- Electron Printing not working on Windows (Works on Mac)
Related Questions in SERVICE
- Why does Angular ^17 have problems with my modules, services, etc
- Problem with Android App background service stoping
- How to use interceptors with services in nestjs
- Exchange data between a Windows service and an application
- Unable to resolve service name to its IP inside kubernetes cluster
- Self Hosted Agent service startup getting failed on VM restart
- Linux service stops logging
- Disable/Enable OSB proxy service via WLST
- Write rows on destination even when an error occurs?
- paho mqtt java cannot reconnect after a long time machine sleep
- IServiceCollectionConfigurator' does not contain a definition for 'UsingRabbitMq'
- "setOngoing(true)" Notification dismissed by user
- How to run powershell command in OnStart of ServiceBase Class in C#?
- Is there any way to globally override Android's back button click?
- Terraform Azure Provider: Authenticating using a Service Principal with a Client Certificate
Related Questions in ADO.NET
- Passing parameters in C# to SQL Server stored procedure - too many arguments specified
- How to increase data reading performance of returned cursor value ADO.NET with Oracle Reader
- Why is calling T-SQL INSERT with SELECT @@IDENTITY inserting duplicates?
- c# - Managing transactions
- Unable to cast object of type 'System.DBNull' to type 'System.Int32' exception in ADO.NET
- DataGridView binded to a DataSet doesn't get updated from another form
- The fastest way to UPDATE multiple rows in C# ADO .NET
- How not to load navigation properties in datagridview using Entity Framework?
- Merge query to upsert data is always inserting the data when run from .NET 6 Web API
- Get all users of an Ado or TFS project
- Call a postgres SP using ADO.NET with parameter as Custom Type
- Calling AJAX methods in parallel increases server response time?
- Issue in Connecting to SQL Server 2008 R2 from .Net application on a different Server
- How to use variable from behind codes on a server tag attribute in listview in ASP.NET using C#
- Operand type clash: int is incompatible with date in sql
Related Questions in SQLCONNECTION
- Problem with connection timeout SQL Server
- How can I run my C# app using a SQLConnection to SQL Server with Windows Authentication in a PC not joined to domain?
- Login failed for user 'NT AUTHORITY\SYSTEM'. Reason: Failed to open the explicitly specified database 'icare'. [CLIENT: <local machine>]
- Do I need to use Dependency Injection with a simple IDbConnection
- connection failed: Connection refused Is the server running on host "127.0.0.1" and accepting TCP/IP connections on port 5432?
- How do I safely take in user input to build another string in my Flutter app?
- Powershell and SQL Connection String Error
- Visual Studio 2022 Pro is giving the error "The connection properties object must be of type SqlConnectionProperties or OleDBSqlConnectionPropertiies"
- SQL Connection Error 0 — if I start my Program from Visual Studio. It works from the build executable if started separately
- Visual Basic, SQL cannot be closed
- I have a deadlock on a distributed transaction in a .NET 8 environment, but I don't understand how to resolve it
- Question on how to correctly use SQL Connections
- Why my query timeout after use the existing SqlConnection to new DbContext(DbConnection existingConnection, bool contextOwnsConnection)?
- VB SqlConnection object missing
- How to solve ER_ACCESS_DENIED_ERROR
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Database connections are considered an "expensive" resource, and as such should be opened only when needed, and closed immediately thereafter. As a result, opening a connection early and persisting it would go against that philosophy. Additionally, doing so prevents your underlying framework from making best use of whatever variety of connection pooling it may implement. It just isn't a very scalable practice.