The best way to do this is not to let developers anywhere near the connection string, but to give them a series of methods that handle it for them.
So we have a separate library that does connection management.
Conclusion Table adapters don’t seem to be giving us many advantages when compared with data adapters, and are giving us problems with our connection management. Component) so we can’t pass them into a separate library in the same way as Data Adapters.We could give them a custom interface and pass them in, or just extract the underlying adapter and pass that in, but this isn’t giving us any advantages over a data adapter and involves more code.In database-locking parlance, the term optimistic concurrency means that your application assumes that no one else will be making changes to the same record that it is currently editing.I explored this concept in detail in a previous article, along with how ADO.Every Table Adapter is capable of creating its own new Connection object.There’s no easy way of overriding that so that whenever a Table Adapter is instantiated it will call out to use a Connection provided by another component.NET automatically supports this locking method at the Data Adapter level via the Data Adapter Configuration Wizard.Although the Data Adapter Configuration Wizard generates code to check for optimistic concurrency violations, it does not handle the errors itself.In general we don’t want connections to be available in the Table Adapters component at all.If anyone can help with this it would be appreciated. I am personally paranoid about this because several years ago I was given responsibility for a project that had a number of fundamental problems. Connections would be cached and then just re-used assuming they were open.