I am making a site and i use entity framework to connect to the database.
Should I put a
try
{
var query = from es in gr.sales
orderby es.tilbudsNavn
select es;
}
catch
{
lblError = "Sorry but you can't connecto to the database right now, try again later";
}
around all my database connections??
Probably not – unless you want to ignore cases where you can’t connect to your database (which would probably render it useless). Some appropriate error handling where you redirect to an error page and if possible perform some sort of notification (i.e. send you an email with details of what the error was) would be much more useful.