Member 11228069 wrote:
3 tier app: UI,CAR OBJECT,DATA ACCESS
Those are
layers, not tiers -- layers are awesome.
Don't try to write one method that will perform all the data access; write a method for each operation that needs to be performed -- and use parameters to provide values to the statements.
Performance can be improved by reusing objects rather than throwing them out and recreating them. This, of course, assumes a system that does a
lot of operations. It may not matter much in your current situation, but you could run into a situation in the future where it
does matter, and developing good habits now will pay of later.
I recommend you not use DataAdapters, but if you do, remember that the adapter will open and close the Connection for you, so you needn't do that.
That
catch
is a
very bad idea; not only does it not provide any benefit, it actually makes things worse. Either...
0) Simply remove the try/catch
1) Add some information to the Data property of the Exception --
e.Data [ "CommandText" ] = selectStr ;
and rethrow ; --
throw ;
2) If you want to throw a
more informative Exception, then include the original Exception as the InnerException --
throw new UnableToFetchDataException(e.Message,e);
3) Both 1 and 2 (recommended)