I really want to the Database instance would be static

Topics: Data Access Application Block
Sep 16, 2011 at 9:39 AM

i'm eager to know there is any question if the Database instance as a static public.

code such as 


public Datahepler


private static Database db=null;

public static Database DB




return db;




some class :

DbCommand cmd= DHHelp.DB.GetSqlCommand(string)



Sep 18, 2011 at 6:53 PM


I don't find any issue on that. Quoting from Christ Tavares on StackOverflow:

"You can (make database object static), but there's no significant reason to. Database instances are cheap to create and don't hold any state."

Hope this helps.


Noel Angelo Bolasoc
Avanade Software
Avanade, Inc.
Contact Us