By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,962 Members | 1,998 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,962 IT Pros & Developers. It's quick & easy.

Declarative use of sqlDataSource in ASP.net 2.0 and Exception Hand

P: n/a
I have been enjoying the declarative use of the new sqlDataSource in asp2.0.
It makes paging and query building extremely quick and simple. However
occasionally I expect to get a timeout exception. Without filling the
sqlDataSource manually I don’t know how to go about catching an exception.
(Most likely but not limited to a timeout exception) I certainly don’t want
to leave an unhandled the exception. And I would like to give a friendly
custom message to the user describing what went wrong in trying to service
their request. (I would prefer not to redirect them to a generic error
page.) I have read lots of examples of the no code configurability of the
sqlDataSource but have not seen any that demonstrated any kind of exception
handling. Does anyone know how to handle exceptions when using the
sqlDataSource control declaratively?

Thanks,
Jeff

Feb 1 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi Jeff,

Welcome to the MSDN newsgroup.

As for the SqlDataSource control you mentioned, current it dosn't contain
such a event which can capture all the exceptions raised in the
SQLDatasource's functions(like connecting , selecting or updating...).
Generally speaking to provide such a centralized event handing method, the
control should have a certain function which calls all the other sub
functions sequentially so that it can use a large try...catch... block to
wrap them. And the ASP.NET web application's Application_Error and
Page_Error event is just implemented based on this(they use try...catch...
to wrap the asp.net request's serverside pipeline or the page's executiong
function----- processRequest). For Datasource control, it dosn't have such
a function, so it's hard to provide such a centralized exception handling
event. So far if you need to capture all the unhandled exceptions could
happend on a certain data source control, we may have to use the page_error
event. However, I do agree that it's a good idea if the sqldatasource
control can expose some event or setting for controling the connecting
operation to the server, I suggest you make the request to the MSDN
feedback site:

http://lab.msdn.microsoft.com/produc...k/default.aspx

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Feb 2 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.