Shared DB or not?

Topics: Data Access Application Block
Oct 28, 2007 at 10:14 AM
Edited Oct 28, 2007 at 10:16 AM
i need to use the DAAB to access 2 db's and run a few hundred stored procedures. in my DAL i created functions for each data access needed. my question: do i need in each DAL function to call the function DatabaseFactory.CreateDatabase() (or a generic function that will internally call the DatabaseFactory.CreateDatabase() function) or can i create a single shared instance on a common class and have all my function use that shared class?

in other words, which code is better/more correct?
Friend Shared DB As Database = DatabaseFactory.CreateDatabase()
and all code referes to the DB variable
Friend Shared Function GetDB() As DataBase
Return DatabaseFactory.CreateDatabase()
End Function
and each function runs the GetDB function and uses the returned value
Oct 30, 2007 at 1:51 PM

Using a single instance per connection string should be fine.