Relative Content

Tag Archive for database

DB Object passing between classes singleton, static or other?

So I’m designing a reporting system at work it’s my first project written OOP and I’m stuck on the design choice for the DB class.
Obviously I only want to create one instance of the DB class per-session/user and then pass it to each of the classes that need it. What I don’t know it what’s best practice for implementing this. Currently I have code like the following:-

keeping connection open all time in sql

I have developed a Windows application in c# in which multiple users can add some numbers and their name and can view the data entered. The problem that I have is that the sever is on my laptop and every time I log off or close my laptop, they are losing connection to the DB and can not add or view any more.