Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > exception handling for ora-00001
 

exception handling for ora-00001

i'm deloping a windows forms database application

in that i inserted one row and agin i'm trying to insert that row.

obviously, we get the error ora-00001

we can handle that error using 'Exception'

are there any predefined exception handlers for this error

if not ,pls explain me how to handle that error in a user friendly manner?

pls help me

thanling you

chaitanya m.
Chaitanya.M  Saturday, July 11, 2009 5:20 PM
Hi Chaitanya.M,

Ora-00001 is an oracle error code for "unique constraint violated". One solution is to check before insert/update, that can avoid insert/update duplicate value to a unique column. The other way is catch the exception message and replace it with your own word.
E.g.
catch (Exception exp)
{
if (exp.Message.Contains("ora-00001"))
{
throw new Exception("Cannot insert duplicate value to XXX column!");
}
}

Sincerely,
Kira Qian
Please mark the replies as answers if they help and unmark if they don't.
  • Marked As Answer byChaitanya.M Thursday, July 16, 2009 12:27 PM
  •  
Kira Qian  Tuesday, July 14, 2009 5:58 AM
Hi Chaitanya.M,

Ora-00001 is an oracle error code for "unique constraint violated". One solution is to check before insert/update, that can avoid insert/update duplicate value to a unique column. The other way is catch the exception message and replace it with your own word.
E.g.
catch (Exception exp)
{
if (exp.Message.Contains("ora-00001"))
{
throw new Exception("Cannot insert duplicate value to XXX column!");
}
}

Sincerely,
Kira Qian
Please mark the replies as answers if they help and unmark if they don't.
  • Marked As Answer byChaitanya.M Thursday, July 16, 2009 12:27 PM
  •  
Kira Qian  Tuesday, July 14, 2009 5:58 AM
thak u very much
Chaitanya.M  Thursday, July 16, 2009 12:27 PM

You can use google to search for other answers

Custom Search

More Threads

• nOT ABLE TO pRINT USING report viewer
• Datagridview find text(Search)
• How do I bind a dataset relationship to a grid view ?
• Formatting the datagrid with alternating row style.
• Slow Database Update
• Add a row to DataGridView
• .net 2.0 - datagridview clear a cell
• Combo box in data grid
• ComboBox and TextBox in DataGridView
• Binding expressions to textbox, label etc