Click here to Skip to main content
15,888,351 members
Home / Discussions / C#
   

C#

 
GeneralRe: Response.Write doenst work correctly ...? Pin
Dave Kreskowiak31-Jul-12 2:29
mveDave Kreskowiak31-Jul-12 2:29 
QuestionHai sir Pin
Mars selva30-Jul-12 20:00
Mars selva30-Jul-12 20:00 
AnswerRe: Hai sir Pin
Abhinav S30-Jul-12 20:08
Abhinav S30-Jul-12 20:08 
QuestionQuick Data Layer Design Question Pin
Kevin Marois30-Jul-12 8:54
professionalKevin Marois30-Jul-12 8:54 
AnswerRe: Quick Data Layer Design Question Pin
Pete O'Hanlon30-Jul-12 10:06
mvePete O'Hanlon30-Jul-12 10:06 
GeneralRe: Quick Data Layer Design Question Pin
Kevin Marois30-Jul-12 10:25
professionalKevin Marois30-Jul-12 10:25 
AnswerRe: Quick Data Layer Design Question Pin
Eddy Vluggen30-Jul-12 11:32
professionalEddy Vluggen30-Jul-12 11:32 
AnswerRe: Quick Data Layer Design Question Pin
BobJanova31-Jul-12 0:27
BobJanova31-Jul-12 0:27 
Exceptions should be handled where they make sense. That's generally in the business logic, because you don't know enough in a data access method to know what a proper resolution is. However, it can make sense to catch and rethrow a new exception, if the exceptions you receive in data access are specific to the data source you're connecting to, because the whole point of layered design is that the logic layer is insulated from the actual data source, so you don't want to be leaking SqlExceptions up to it.

The logic should be designed so that 'obvious' failure cases never get to the DAL, though. In this case I'd expect a user name to be checked for existence before trying to add it, because that's a nicer time to get a message so the user can fix it. And I'd expect the company and role to be picked in a constrained way so the FK can't fail in normal circumstances. DAL methods should only fail if something unexpected happens (e.g. database goes down, race condition between clients causes the data to no longer be valid, etc). The DAL should still handle failure gracefully but it shouldn't be common.

And yes, I'd throw an exception if the user existed, though I think I'd do that just by assuming it doesn't and letting the INSERT fail in the case that it does. Note that your current code can still fail if someone else INSERTs a user with that name between your check and the addition! You might as well just try the addition and let it fail, since you have to protect it anyway.
AnswerRe: Quick Data Layer Design Question Pin
PIEBALDconsult31-Jul-12 6:33
mvePIEBALDconsult31-Jul-12 6:33 
QuestionCircular list as vector, lock needed? Pin
George Nistor30-Jul-12 5:45
George Nistor30-Jul-12 5:45 
AnswerRe: Circular list as vector, lock needed? Pin
OriginalGriff30-Jul-12 6:07
mveOriginalGriff30-Jul-12 6:07 
GeneralRe: Circular list as vector, lock needed? Pin
dybs30-Jul-12 8:07
dybs30-Jul-12 8:07 
GeneralRe: Circular list as vector, lock needed? Pin
OriginalGriff30-Jul-12 8:12
mveOriginalGriff30-Jul-12 8:12 
GeneralRe: Circular list as vector, lock needed? [Modified] Pin
Wes Aday30-Jul-12 8:51
professionalWes Aday30-Jul-12 8:51 
GeneralRe: Circular list as vector, lock needed? Pin
George Nistor30-Jul-12 21:43
George Nistor30-Jul-12 21:43 
GeneralRe: Circular list as vector, lock needed? Pin
George Nistor30-Jul-12 23:48
George Nistor30-Jul-12 23:48 
Questionc# Pin
sutapa das29-Jul-12 20:30
sutapa das29-Jul-12 20:30 
AnswerRe: c# Pin
Abhinav S29-Jul-12 20:46
Abhinav S29-Jul-12 20:46 
Questionhow to create monthly calander in c#? Pin
sutapa das29-Jul-12 20:27
sutapa das29-Jul-12 20:27 
AnswerRe: how to create monthly calander in c#? Pin
Midnight Ahri29-Jul-12 20:40
Midnight Ahri29-Jul-12 20:40 
GeneralRe: how to create monthly calander in c#? Pin
Richard MacCutchan29-Jul-12 21:54
mveRichard MacCutchan29-Jul-12 21:54 
AnswerRe: how to create monthly calander in c#? Pin
Dave Kreskowiak30-Jul-12 2:19
mveDave Kreskowiak30-Jul-12 2:19 
QuestionApplication Level Key Shortcut Pin
Jassim Rahma29-Jul-12 11:54
Jassim Rahma29-Jul-12 11:54 
AnswerRe: Application Level Key Shortcut Pin
Richard Andrew x6429-Jul-12 12:19
professionalRichard Andrew x6429-Jul-12 12:19 
GeneralRe: Application Level Key Shortcut Pin
Trak4Net29-Jul-12 20:30
Trak4Net29-Jul-12 20:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.