views:

196

answers:

2

Hi,

I'm testing database programming in vb.NET 2008 at the moment and try to find a way to use a database connection in different forms, so e.g. I put the the database-connection-component into one of the forms.

I know, I could access it by e.g. form1.databaseconnection.xxx, but is this the best way or can I "put" the connection into something more abstract which all forms know about?

Thanks

+2  A: 

Better if you implement a Data Access Layer on a separate Class Libraray project and add a reference to it on you windows application project.

Jojo Sardez
A: 

I had to take a pretty similar design decision, and I decided that it would be the best to share the connection from one major object, and hand it to Forms by calling an overloaded Show()-Method.

Public Overloads Sub Show(ByVal mainController As MyController)
    _handedController = mainController
End Sub

MyController is a class which holds several important things, like the DB-Connection etc. .

Bobby