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

G

Guest

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
 
S

Steven Cheng[MSFT]

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/productfeedback/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.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top