G
Guest
Hi. I have the following requirement and I don't know which way I should approach it
In a 3 tier application, the business layer calls a function in the data access layer; the data access layer function opens an Oracle connection, execute an "ExecuteScalar" instruction, closes the connection and returns the result to the business layer
I would like to know which is the best way for handling both database errors and invalid data
Right now, I wrapped connection.open and command.executescalar in a try/catch block with connection.close in the finally statment. Should I not do that? Should I move the try/catch block in my business layer wrapped around the data access layer function call? Btw, what is the difference between connection.close and connection.dispose - some MS examples have connection.close while others have both
Where should I do my data validation? For example, should I throw an exception if the executescalar returns a null, that I should catch in the business layer, or should I have an IIf(retVal.IsDBNull, -1, retVal) statement? Is the data access layer supposed to return clean data
Thank
TM
In a 3 tier application, the business layer calls a function in the data access layer; the data access layer function opens an Oracle connection, execute an "ExecuteScalar" instruction, closes the connection and returns the result to the business layer
I would like to know which is the best way for handling both database errors and invalid data
Right now, I wrapped connection.open and command.executescalar in a try/catch block with connection.close in the finally statment. Should I not do that? Should I move the try/catch block in my business layer wrapped around the data access layer function call? Btw, what is the difference between connection.close and connection.dispose - some MS examples have connection.close while others have both
Where should I do my data validation? For example, should I throw an exception if the executescalar returns a null, that I should catch in the business layer, or should I have an IIf(retVal.IsDBNull, -1, retVal) statement? Is the data access layer supposed to return clean data
Thank
TM