Quote Originally Posted by gwboolean View Post
OK, I get the idea that you believe that having a function or method that is located in a class/module and used by many different methods from many different locations is a bad thing and screws up processes. Now why is that so? What is a standard way?


I do not pretend to know much about VB coding processes, it has long been presented to me that doing that is both efficient and less problematic.
Having a reusable method that can be called from multiple places is a good idea, however it does require the method in question to be implemented with this in mind.

A typical approach would be to have the function return the data to the calling code, that way each caller gets a version of the data specific to the caller. If you call the function twice, then you return two pieces of data that are completely separate from each other.

IIRC your MasterBase approach is using global variables / Shared properties to manage the returned data - this means if you call it twice then the second execution effectively overwrites the data from the first execution. Using this kind of global data makes it incredibly difficult to maintain the function, often leading to hard to track down bugs due to this shared data being changed in unexpected ways / at unexpected times.

You could have implemented the Data Access functionality as a class, that way you could create a new instance of the class each time you need access to the database, each instance would have it's own connections etc. and therefore multiple instances wouldn't interfere with each other.