0

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 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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. .

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.