I have a general "Best Practices" question...
What is the best way to pass the database connection string/object to custom objects?
They way I've been doing it is that I have the connection object as a parameter of my save function...
So when I make the save call i do...
I could not think of a better way to do this and not have the connection string in each one of my custom objects. I want the objects to be as generic as possible so I want to pass in which database to connect too.
Is it better to pass in the connection information when the custom object is created?
Or is there a way to setup my program that the custom object will know where to look to acquire the connection information?
Hopefully it's clear on what I'm looking for...
Does anyone have a "best practice" method of doing what I want?
What is the best way to pass the database connection string/object to custom objects?
They way I've been doing it is that I have the connection object as a parameter of my save function...
Code:
Public Class Cars
Public Function Save(con as oledbConnection) as boolean
.....
End Function
End ClassCode:
obj.Save(g_odb.dbConnection)
'-->g_odb.dbConnection is my connection objectIs it better to pass in the connection information when the custom object is created?
Or is there a way to setup my program that the custom object will know where to look to acquire the connection information?
Hopefully it's clear on what I'm looking for...
Does anyone have a "best practice" method of doing what I want?