Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 11th, 2005, 04:05 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp
Default catching the database exceptions

I am about to start the design & development of a fairly big ASP.Net application with SQL Server 2000. There are many a number of entities, relationship between entities, constraints and complex data integrity rules.

I would like to depend on database features for ensuring data integrity. That is by using check constraints, unique constraints, foreign key constraints, triggers and the nullable property of fields, I will set all the data integrity rules in the database. I would like to avoid any explicit ASP.Net validations in aspx / cs / http handler files. Instead, I want to catch the db errors and show appropriate error messages. It should be possible to show appropriate error message (Not just showing "some error in the submitted data etc. etc.").

My doubt is, whether this is possible ? If yes, how can I do it ?

NB : Previously, I was checking all posted data with either validator controls or server side ASP.Net. This is very difficult and not maintainable also. Each validation change requires integrity rule changes at database level as well as code changes. I would like to get rid of script level data validations.

Thanks

Madhu
 
Old March 11th, 2005, 01:02 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

You can do this using Try...Catch statements. See the help files for specifics.
 
Old March 11th, 2005, 03:13 PM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 336
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alyeng2000
Default

For sql2000

Try
....
Catch e as SqlClient.SqlException
...
Finally
....
End Try

Ahmed Ali
Software Developer
 
Old March 12th, 2005, 12:45 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp
Default

Thank you Benson and Ahmed. I am trying this now and seems to be possible.





Similar Threads
Thread Thread Starter Forum Replies Last Post
exceptions Maxxim BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 3 October 18th, 2008 12:34 PM
Catching Up John Kauffman BOOK: Beginning ASP.NET 2.0 and Databases 2 October 2nd, 2006 05:04 PM
catching error darkhalf Javascript 4 December 14th, 2005 01:44 PM
Catching exceptions thrown from an event... jacob C# 5 December 6th, 2005 12:48 PM
When to use Exceptions kcraft Pro PHP 1 January 15th, 2005 02:37 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.