I have a connection string in my web.config - to which I then refer to in my code through all my controls, they're all databound to it.
Anyway - how do I catch any errors - such as when I want to view the website on a train, if I'm working on it.
I don't want it to crash and burn [the site, not the train] - if I dont have access to the sql server.
How can I wrap it in a try block!?- How do i then deal with controls which refer to the connection string?
One solution I thought of - is to programmatically set all the databinding - and not just with the GUI. As that way I can wrap everything in a try{}catch{} block.
Any other - site-wide way of doing this?
Thank you,
R
If it's a connstrings error, then one way would be to try them when the application starts up.
If you are looking for error handling during the select/insert/delete events of a sqldatasource, then check the errors in the selected/inserted/deleted events, and set e.errorhandled property to true (or not if you want the default error handling). Of course, that's not site wide.
|||i want to capture an error at web.config stage.
so if you have something like this in your web.config:
<add name="DataStoreConnectionString" connectionString="Data Source=.\sqlexpress;Initial Catalog=mehDB;Integrated Security=True;uid=submit;pwd=" providerName="System.Data.SqlClient"/>
then have it produce an error on the site - and not just prevent the website from loading. as the database component althogh significant, only is necessary for logged in users - so not to affect users that are just browsing.
how do i catch the error at such an early stage?
thank you.
No comments:
Post a Comment