Friday, February 17, 2012

Error Handling with SQLDataSource

Hello to all

I am having a SQLDataSource on my web page to connect with database. Now If it generates any error then where to capture that errors ?? Means at which place(which event or any other place) should i write code for handeling errors ?

Which programming language (e.g. C#) do you use for your web page? In C#, you can use a 'try...catch' block to catch the exception when connect to SQLDataSource; you can perform the connection action in a 'button click' event or in page load event as you like.|||

Yes I know in C# I can use Try--catch. But on which event Do I use Try and Catct ?

If I use this on "selecting " it does not have any effect...

|||Yeah im also wondering how to do this.

The sql data source is loaded when the page loads and runs the select command, so it is not run when a button is pressed.|||You can handle the error on the Inserted, Deleted and Updated events. (They all have Exception properties, and if you handle it, you can set ExceptionHandled to true.)|||Hi,

I have a similar question : How do I handleconnection exceptions ?

mpswaim:

You can handle the error on the Inserted,Deleted and Updated events. (They all have Exception properties, and ifyou handle it, you can set ExceptionHandled to true.)

When the server is unavailable, the exception property of the selected event is null.

Thanks,

Loïc

No comments:

Post a Comment