G
Guest
Hi all,
Just throwing something out to the newsgroup to get a feel for what others
are doing.
I am noticing that with my current coding practice, every time i want to
update a database i generally implement the following pattern.
1) Open db connnection
2) Execute Query
3) Close Db Connection
Having written numerous events / methods that require db access, i am
getting tired of having to manage the Db connection in each routine; ie
create and close a connection like so.
//create db connection
SqlConnection Cn = new
SqlConnection(ConfigurationSettings.AppSettings["ConnStr"]);
//open db connection
Cn.Open();
//close db connection
Cn.Close();
Apart from laziness, i have realized when a post back requires a number of
actions I am opening & closing the database numerous times, and wonder how
efficient
it is.
How does everyone else handle their db work.
Does anyone else have a method that allows you to reuse an existing Db
Connection? A singleton class ect???
I am about to add a DAL to an existing 1.1 project....how would ya'll manage
your db connections in their.
Would love any sample code and / or tutorials ?
Input appreciated.
Adam
Just throwing something out to the newsgroup to get a feel for what others
are doing.
I am noticing that with my current coding practice, every time i want to
update a database i generally implement the following pattern.
1) Open db connnection
2) Execute Query
3) Close Db Connection
Having written numerous events / methods that require db access, i am
getting tired of having to manage the Db connection in each routine; ie
create and close a connection like so.
//create db connection
SqlConnection Cn = new
SqlConnection(ConfigurationSettings.AppSettings["ConnStr"]);
//open db connection
Cn.Open();
//close db connection
Cn.Close();
Apart from laziness, i have realized when a post back requires a number of
actions I am opening & closing the database numerous times, and wonder how
efficient
it is.
How does everyone else handle their db work.
Does anyone else have a method that allows you to reuse an existing Db
Connection? A singleton class ect???
I am about to add a DAL to an existing 1.1 project....how would ya'll manage
your db connections in their.
Would love any sample code and / or tutorials ?
Input appreciated.
Adam