Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Ado.net contain two Architecture

1.connected Architecture
2. disconnected Architecture


performance wise which is faster connected Architecture or disconnected Architecture in ado.net

What I have tried:

Ado.net contain two Architecture

1.connected Architecture
2. disconnected Architecture


performance wise which is faster connected Architecture or disconnected Architecture in ado.net
Posted
Updated 20-Nov-17 13:12pm

1 solution

Neither. Depends on the circumstances of the code and data, the problem being solved, and the approach to solving it. There is no "one architecture works for all" approach here.

Having your application constantly connected (connected architecture) to the SQL Server is a BAD idea. You're hogging licensing and other resources of the SQL Server and forcing your application and the server into a position where it scales poorly.

You should be opening a connection as late as possible, doing your query work, then closing the connection as early as possible.

Having said that, how often you open a connection and keep it open depends on the operation your performing on the data.

If you've got thousands of records to INSERT, opening and closing a connection for each of those operations is costly to performance. You should process all of the data as much as possible, open the connection, do all of the INSERT operations, then close the connection.

Keeping a connection open all the time, limits the number of connection you can have open on the server because of resources. You also have more complex code because what if the connection is broken some time during your applications lifetime? How are you going to handle detecting and reestablishing the connection?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900