You might want to not reinvent the wheel.
http://davidhayden.com/blog/dave/arc...1/08/2686.aspx
http://www.google.com/search?hl=en&q...%22+%22data%22
I would rely on "open late" / "close early".
But the source code for the EnterpriseLibrary would provide ideas if you
want to keep going .
"Adam Knight" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi all,
>
> I am wanting to create a re-useable class to manage db connections in an
> app.
>
> This is what i have so far:
>
>
> using System;
> using System.Data;
> using System.Data.SqlClient;
> using System.Configuration;
>
> public class DBUtil
> {
>
> public DBUtil()
> {
>
> }
>
> public static SqlConnection Conn
> {
>
> get {
>
> //return DB connection
> return Conn;
>
> }
> set {
>
> //determine if a db connection is already established
> if (Conn == null)
> {
>
> //establish a connection to the db
> Conn = GetDBConnection();
>
> }
>
> }
>
> }
>
> public static SqlConnection GetDBConnection()
> {
>
> //retrieve connection string for db from web config
> string ConnString =
> ConfigurationManager.ConnectionStrings["TestCenterDB"].ConnectionString;
>
> //establish a connection to the database
> Conn = new SqlConnection(ConnString);
>
> //open db connection
> Conn.Open();
>
> //return db connection
> return Conn;
>
> }
>
> public static void CloseDBConnection(SqlConnection Conn)
> {
>
> //close db connection
> Conn.Close();
>
> }
>
> }
>
> Would appreciate any ones thought and suggestions on possibly a better
> approach or improving what i have some far!!!!
> .Is my logic ok? I suspect it isn't quite right???
>
> Cbeers,
>
>