Andy wrote:
> I have a C# application that is using a DataGridView (DGV). The DGV uses
> a table adapter to connect to the datasource, which uses a DataSet as the
> data. The DataSet has some constraints placed on them (PK on two columns).
>
> When I add / update a column that violates the PK constraint, I get an
> error stating the following:
>
> System.Data.ConstraintException: Column 'Item, BItem' is constrained to be
> unique. at System.Data.UniqueConstraint.CheckConstraint........at
> System.Windows.Forms.DataGridView.DataGridViewDataConnection.OnRowValidating.
> To Replace this default dialog please handle the DataError event.
>
> I cannot for the life of me find how to replace that "default dialog" or
> how to trap for this error message. I know it must be in the DataSet
> configuration, but not sure where to place a try.....catch. Google didn't
> provide any results that helped correct this.
You're looking in the wrong place. The DataError event is raised by your
instance of DataGridView. More info on this event can be found at
http://msdn2.microsoft.com/en-us/lib...dataerror.aspx,
including a little bit of sample code.
--
Tom Porterfield