CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML

Free Download:




Zone: > NEWSGROUP > Asp.Net Forum > visual_studio.visual_studio_2005 Tags:
Item Type: NewsGroup Date Entered: 2/15/2007 11:34:20 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 1 Views: 44 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
2 Items, 1 Pages 1 |< << Go >> >|
Dataconsult
Asp.Net User
Errorhandling Try Catch with detailsview2/15/2007 11:34:20 AM

0/0

Dear readers,

How can I create friendly error messages in combination with a detailsview created in VS2005?  I don't want to let the users put duplicate family details in my database.  so I've created an index with Firstname, Lastname and Zip Code.  Thats enough for the moment.  When I now enter a family which is already in the database I get the message "Violation of UNIQUE KEY constraint 'IX_SEP_IN_TA_Famin'. Cannot insert duplicate key in object 'SEP_IN_TA_Famin'. The statement has been terminated"

How can I change this in a friendly message?

In asp.net 1.0 when I coded a form to insert, update and then I used the code:
Command1.Connection.Open()
  Try
    Command1.ExecuteNonQuery()
    Label1.Text = "The family is created."
  Catch Err As Exception
    If err.Message.IndexOf("UNIQUE KEY") >= 0 Then
      'Family already exist
      Label1.Text = "The family already exists in the database, you can't add this family again."
   End If
   Finally
End Try
Command1.Connection.Close()

How can I implement this in a detailsview?

Kind regards,

Bart

DMW
Asp.Net User
Re: Errorhandling Try Catch with detailsview2/15/2007 12:50:45 PM

0/0

Add a handler for the DetailsView's ItemInserted event.

Check the Exception property of the DetailsViewInsertedEventArgs. Take whatever action you deem to be appropriate. If you don't want the exception to be propagated onwards, set the ExceptionHandled property (of the DetailsViewInsertedEventArgs) to True.


Dave
2 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Beginning ASP.NET 2.0 Databases: From Novice to Professional Authors: Damien Foggon, Pages: 625, Published: 2006
Pro ASP.NET 2.0 in C# 2005 Authors: Matthew MacDonald, Mario Szpuszta, Pages: 1255, Published: 2005
Pro ASP.NET 2.0 in VB 2005: From Professional to Expert Authors: Laurence Moroney, Matthew MacDonald, Pages: 1253, Published: 2006
Professional ASP.NET 2.0 Databases Authors: Thiru Thangarathinam, Pages: 504, Published: 2007
Pro ASP.NET 2.0 in C# 2005: Create Next-generation Web Applications with the Latest Version of Microsoft's Revolutionary Technology Authors: Matthew MacDonald, Mario Szpuszta, Pages: 1426, Published: 2006
Beginning ASP.NET 2.0 in VB 2005: From Novice to Professional Authors: Matthew MacDonald, Pages: 1063, Published: 2006
The Definitive Guide to the .NET Compact Framework Authors: Larry Roof, Dan Fergus, Pages: 1009, Published: 2003
Wrox's ASP.NET 2.0 Visual Web Developer 2005 Express Edition Starter Kit: visual web developer 2005 express edition starter kit Authors: David Sussman, Alex Homer, Pages: 312, Published: 2005
Professional C# 2005 Authors: Christian Nagel, Bill Evjen, Jay Glynn, Karli Watson, Morgan Skinner, Allen Jones, Pages: 1540, Published: 2006

Web:
FormView Error Handling Talk about FormView Error Handling. ... try { throw new Exception("test"); catch (Exception e) { } e.Exception is always null, ...
FormView - Insert Record (Try Catch Finally) - ASP.NET Forums No need to use a Try/Catch as you can use either the Inserted event handler ... see if the Exception property is Nothing prior to doing our error handling. ...
Updating and deleting data using Gridview or Detailsview in VWD ... Triggers Error Handling in MS-SQL Server 2000 You cannot catch most errors using Try/catch or @@Error. It will simply terminate and roll back. ...
FormView Catch Error When Deleting?? : Microsoft, ASP.NET, 2.0 I have try catch in each of these events, but when the record i'm deleting causes an ... this line works fine everywhere else. it is custom error handling. ...
catch sql exception Wrap the SQL call within a TRY-CATCH. ie: Try DataConnection.Open ... Catch ex as exception Do your error handling here. your error is ex. ...
WorldofASP.NET: Error Handling techniques in ASP.NET 2.0 | ASP.NET ... In .NET framework , the simplest and easiest way to handle your code error is by placing your code inside try and catch blocks. However this doesn't mean ...
FormView (DigitalColony.com) This site uses Blogger, which is not 100% XHTML compliant. Try...Catch Disclaimer: For brevity many examples do not include error handling. ...
listing b and software Resources | TechRepublic NET 2.0's GridView control with a DetailsView or FormView control. .... the new Try/Catch statement in SQL Server 2005: Error handling has come a long way ...
GridView, DetailsView, and SqlDataSource Interaction Part 1 ... May 9, 2007 ... For instance, the detailsview is usually bound to a gridview selection, ... In the next article, I plan to show some of the error-handling ...
Asp, Sql Server - Builder AU The try/catch block allows you to catch exceptions and control ... This week we examine error handling in your database code with SQL Server and T-SQL. ...




Search This Site:










dnn3 in subfolder under dnn1

digest authentication

looking for a skin

system.security.cryptography uses

admin question

error while browsing http://localhost/dotnetnuke/

vs2005 and references

enhancement - multiple hosts

stylize the solpartactions menu?

where is the "immediate window"?

predefined values in profiles

tttgallery and child portals - solution

how to put js file on all pages?

dnn 4.0.1 - system.security.securityexception: request for the permission of type 'system.security.permissions.fileiopermission

basic authentication force relogin

skins in whidbey

gammacon userdefined table 1.1.0 available - with images and paging

formcreator module

source missing ?

does asp.net 2.0 membership support access checking to arbitrary objects?

enable and disable menuitems

site administration

how big sql database is needed for 3.1.1

image can't be displayed at all...:(

no site content showing

excel error when using reportviewer

using roles with windows authentication

dynamic menu based on database table

annoying dialog

datagrid not supporting certain properties.

 
All Times Are GMT