SqlDataSource is doing an Update after handeling an Insert excepti

Discussion in 'ASP .Net Web Controls' started by masmith, Feb 20, 2009.

  1. masmith

    masmith Guest

    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
    masmith, Feb 20, 2009
    #1
    1. Advertising

  2. masmith

    masmith Guest

    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


    "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
    masmith, Feb 20, 2009
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mike P
    Replies:
    0
    Views:
    2,282
    Mike P
    Mar 12, 2005
  2. mosscliffe
    Replies:
    3
    Views:
    9,426
    mosscliffe
    Apr 28, 2006
  3. Jason
    Replies:
    2
    Views:
    1,006
    Jason
    Nov 12, 2006
  4. Luqman
    Replies:
    5
    Views:
    1,405
    luqman
    Nov 22, 2007
  5. Jason
    Replies:
    0
    Views:
    254
    Jason
    Nov 12, 2006
Loading...

Share This Page