Home All Groups Group Topic Archive Search About

SqlDataSource is doing an Update after handeling an Insert excepti

Author
20 Feb 2009 3:23 PM
masmith
I am using VS 2008 to create a ASP.NET 3.5 web page with a third party grid
control and a SQLDataSource.  I have found that adding events for the
SQLDataSource control to handle exceptions that occure during Insert or
Update does work.  The problem is when I set the e.ExceptionHandled = true in
Inserted event, the SQLDataSource then fires an update.  This is a problem as
the error is being caused by a duplicate key violation.  Thus it is updating
the vaild or original row with the duplicate key value with the new insert
values.

I believe the problem is in the SQLDataSource control code as the Insert and
the Update are occuring in the same postback and the update fires as soon as
the insert is complete.

Has anyone else seen this behavior and found a solution?
--
Mark

Author
20 Feb 2009 6:15 PM
masmith
I found that the sqldatasource inserting event has the same problem where I
e.cancel = true when I determine a duplicate key value has been entered.  It
cancels the insert but still fires the database update.

Also I am using Infragistics UltraWebGrid connected to the SQLDataSource.  I
do not believe it is the problem, but I am posting a message with there
support in case I am wrong and it is the server based code for the WebGrid
that is firing the update.

Has anyone seen this problem when using the SQLDataSource?
If yes what control or controls where you binding to the SQLDataSource?
--
Mark


Show quoteHide quote
"masmith" wrote:

> I am using VS 2008 to create a ASP.NET 3.5 web page with a third party grid
> control and a SQLDataSource.  I have found that adding events for the
> SQLDataSource control to handle exceptions that occure during Insert or
> Update does work.  The problem is when I set the e.ExceptionHandled = true in
> Inserted event, the SQLDataSource then fires an update.  This is a problem as
> the error is being caused by a duplicate key violation.  Thus it is updating
> the vaild or original row with the duplicate key value with the new insert
> values.
>
> I believe the problem is in the SQLDataSource control code as the Insert and
> the Update are occuring in the same postback and the update fires as soon as
> the insert is complete.
>
> Has anyone else seen this behavior and found a solution?
> --
> Mark