This is a migrated thread and some comments may be shown as answers.

Capturing Sql Errors on Save

1 Answer 30 Views
Integration with other products
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
David
Top achievements
Rank 2
David asked on 18 Mar 2012, 12:16 AM
Hi,

I have setup an OpenAccess Model and I'm currently testing a few things. I'm using a WinForms app I have added a RadGrid on the form and set the datasource 

this.radGridView1.DataSource = Context.Employees.ToList<Employee>();

I am then using the following events to capture Inserts/Deletes

this.radGridView1.UserAddedRow += new Telerik.WinControls.UI.GridViewRowEventHandler(radGridView1_UserAddedRow); 
this.radGridView1.UserDeletingRow += new Telerik.WinControls.UI.GridViewRowCancelEventHandler(radGridView1_UserDeletingRow);

This all works ok i can add/remove/update values

The issue I'm having is I have a Unique Index constraint on the e-mail column, if I try to add a employee with the same e-mail address then the SaveChanges will throw an exception. No data changes are then saved into the database but this is not flagged in then application  

How should I be handling these sort of errors?

Thanks

1 Answer, 1 is accepted

Sort by
0
Damyan Bogoev
Telerik team
answered on 21 Mar 2012, 05:27 PM

Hi David,

You could use the OpenAccessContextBase.Refresh(RefreshMode mode, IEnumerable entities) method to refresh the state of the persistent capable objects collection when the changes are not persisted to the database.

If any other questions arise, do not hesitate to contact us back.

Greetings,
Damyan Bogoev
the Telerik team
Telerik OpenAccess ORM Q1 2012 release is here! Check out what's new or download a free trial >>
Tags
Integration with other products
Asked by
David
Top achievements
Rank 2
Answers by
Damyan Bogoev
Telerik team
Share this question
or