I'm wondering about the 'dangers' of keeping a database stream open.
currently, i'm using a 'using' statement to keep my database stream open as necessary. BUT, i want to wrap my database up into a Model class and call 'CRUD' methods on the model to get work done.
i'm just wondering when i should open the stream to the database:
1) when i create an object from the model class
2) everytime i call a method
i'll be accessing the database approximately every 20 seconds to add a handful of itecs.
also, i have some rather complex operations to do, but should i just use 1) and keep the set of operations simple? or just a new method for each complex operation?
i'm calling a SQLCE database if that matters
Using a Model class around a SQL Database
Page 1 of 15 Replies - 300 Views - Last Post: 14 August 2011 - 11:53 PM
Replies To: Using a Model class around a SQL Database
#2
Re: Using a Model class around a SQL Database
Posted 13 August 2011 - 10:20 PM
Doesn't matter. When you first make a connection to the database, the .NET library makes multiple connections (referred to as the connection pool) and keeps these connections open until your program ends. This speeds up later connections as it just pulls one from the pool and when you close the connection it returns it to the pool.
You can read about it here: SQL Server Connection Pooling (ADO.NET)
You can read about it here: SQL Server Connection Pooling (ADO.NET)
#3
Re: Using a Model class around a SQL Database
Posted 14 August 2011 - 06:56 AM
Momerath, on 14 August 2011 - 01:20 AM, said:
Doesn't matter. When you first make a connection to the database, the .NET library makes multiple connections (referred to as the connection pool) and keeps these connections open until your program ends. This speeds up later connections as it just pulls one from the pool and when you close the connection it returns it to the pool.
You can read about it here: SQL Server Connection Pooling (ADO.NET)
You can read about it here: SQL Server Connection Pooling (ADO.NET)
Well, it does matter since he is using SQLCE, which doesn't support connection pooling. You SHOULD leave the connection open as long as possible with SQLCE.
http://blogs.msdn.co.../21/431074.aspx
http://csharponphone...and-thread.html
#4
Re: Using a Model class around a SQL Database
Posted 14 August 2011 - 01:06 PM
eclipsed4utoo, on 14 August 2011 - 06:56 AM, said:
Well, it does matter since he is using SQLCE, which doesn't support connection pooling. You SHOULD leave the connection open as long as possible with SQLCE.
http://blogs.msdn.co.../21/431074.aspx
http://csharponphone...and-thread.html
http://blogs.msdn.co.../21/431074.aspx
http://csharponphone...and-thread.html
That's the mobile edition and using SqlCeConnection.
This post has been edited by Momerath: 14 August 2011 - 01:06 PM
#5
Re: Using a Model class around a SQL Database
Posted 14 August 2011 - 07:14 PM
Momerath, on 14 August 2011 - 04:06 PM, said:
eclipsed4utoo, on 14 August 2011 - 06:56 AM, said:
Well, it does matter since he is using SQLCE, which doesn't support connection pooling. You SHOULD leave the connection open as long as possible with SQLCE.
http://blogs.msdn.co.../21/431074.aspx
http://csharponphone...and-thread.html
http://blogs.msdn.co.../21/431074.aspx
http://csharponphone...and-thread.html
That's the mobile edition and using SqlCeConnection.
That's what he's using.
The Architect 2.0, on 13 August 2011 - 10:06 PM, said:
i'm calling a SQLCE database if that matters
#6
Re: Using a Model class around a SQL Database
Posted 14 August 2011 - 11:53 PM
using the built-in SQLCE 3.5(?) 'local database' in VS 2010.
i used sqlmetal.exe to generate the appropriate .dbml files(and the other ones) for linq-to-sql
EDIT:
can someone point me to a good BROAD overview of databases and c#?
i keep hearing about ADO.NET, linq, entity framework, data contexts, dataviews, etc. and its all very confusing.
i used sqlmetal.exe to generate the appropriate .dbml files(and the other ones) for linq-to-sql
EDIT:
can someone point me to a good BROAD overview of databases and c#?
i keep hearing about ADO.NET, linq, entity framework, data contexts, dataviews, etc. and its all very confusing.
This post has been edited by The Architect 2.0: 14 August 2011 - 11:55 PM
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote




|