AdventureWorks Database - error updating an existing row.

Last post 04-04-2008 12:35 PM by Maxer_Ars. 2 replies.

Sort Posts:

  • AdventureWorks Database - error updating an existing row.

    09-01-2006, 9:44 AM
    • Member
      21 point Member
    • johnhbarrett
    • Member since 09-01-2006, 8:51 AM
    • Posts 7

    To reproduce thsi simple install the Aventure works database, run blinq, go to 'ScrapReasons table, edit row 7, update....kabam!

     Any ideas???

    Guess some testing needed against other databases (besides Northwind) ? 

     Row not found or changed.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Data.DLinq.OptimisticConcurrencyException: Row not found or changed.

    Source Error:


    Line 1091:      original_x.Name = x.Name;
    Line 1092:      original_x.ModifiedDate = x.ModifiedDate;
    Line 1093:      db.SubmitChanges();
    Line 1094:      return 1;
    Line 1095:    }
     

    Source File: c:\blinqtest\App_Code\StaticMethods.cs    Line: 1093

    Stack Trace:


    [OptimisticConcurrencyException: Row not found or changed.]
       System.Data.DLinq.ChangeProcessor.ThrowOptimisticConcurrencyException(List`1 failedUpdates, Int32 totalUpdatesAttempted) +182
       System.Data.DLinq.ChangeProcessor.SubmitChanges(ConflictMode failureMode) +620
       System.Data.DLinq.DataContext.SubmitChanges(ConflictMode failureMode) +264
       System.Data.DLinq.DataContext.SubmitChanges() +25
       ScrapReason.Update(ScrapReason original_x, ScrapReason x) in c:\blinqtest\App_Code\StaticMethods.cs:1093

    [TargetInvocationException: Exception has been thrown by the target of an invocation.]
       System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) +0
       System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) +72
       System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) +358
       System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +29
       System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) +17
       System.Web.UI.WebControls.ObjectDataSourceView.InvokeMethod(ObjectDataSourceMethod method, Boolean disposeInstance, Object& instance) +676
       System.Web.UI.WebControls.ObjectDataSourceView.InvokeMethod(ObjectDataSourceMethod method) +60
       System.Web.UI.WebControls.ObjectDataSourceView.ExecuteUpdate(IDictionary keys, IDictionary values, IDictionary oldValues) +2319
       System.Web.UI.DataSourceView.Update(IDictionary keys, IDictionary values, IDictionary oldValues, DataSourceViewOperationCallback callback) +179
       System.Web.UI.WebControls.GridView.HandleUpdate(GridViewRow row, Int32 rowIndex, Boolean causesValidation) +1138
       System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +835
       System.Web.UI.WebControls.GridView.OnBubbleEvent(Object source, EventArgs e) +162
       System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +56
       System.Web.UI.WebControls.GridViewRow.OnBubbleEvent(Object source, EventArgs e) +118
       System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +56
       System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +107
       System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +175
       System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +31
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +32
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +244
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3839

     

  • Re: AdventureWorks Database - error updating an existing row.

    09-01-2006, 1:10 PM
    • Contributor
      2,680 point Contributor
    • phuff
    • Member since 06-11-2002, 8:39 AM
    • Redmond, WA
    • Posts 547
    • AspNetTeam

    This is because the ModifiedDate property is a high-precision date time field.  From the Readme:

    ·         Tables with columns of type DateTime with higher precision than seconds do not update correctly. Blinq creates BoundField objects for DateTime fields that do not contain precision beyond seconds, so updates with DateTime fields with high precision that participate in optimistic concurrency fail. To fix this, do one of the following:

    o        Change the precision displayed by the BoundField object by setting DataFormatString="{0:o}", HtmlEncode=false, and ApplyFormatInEditMode=true.

    o        Designate the DateTime field as never participating in optimistic concurrency. See "Changing a Field’s Update Mode" earlier in this document to change the update mode for this column. Use this option carefully—removing this column from participating in optimistic concurrency will allow overwrites of the value to succeed even if the database’s value has been changed.

     

    Polita Paulus

    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: AdventureWorks Database - error updating an existing row.

    04-04-2008, 12:35 PM
    • Member
      69 point Member
    • Maxer_Ars
    • Member since 02-27-2008, 1:20 PM
    • Posts 167

    The dateformat string solution, are there other ways to deal witht that (other than telling it to NEVER participate in optimistic concurrency)?

    I mean to say, how can that be displayed to the user in a way that is less "awful" for them to look at?

    Could it be tied into some sort of date/time picker control so the user never has to see that? 

     

    EDIT:  What if a datetime stamp was used (added as a whole new field) could optimistic concurrency use that field and then all the other fields would be set to NEVER participate so you'd have the best of both worlds?

Page 1 of 1 (3 items)