Row not found or changed

Last post 03-31-2008 6:58 PM by jessyhoule. 15 replies.

Sort Posts:

  • Row not found or changed

    08-11-2006, 4:34 PM
    • Loading...
    • cankersore
    • Joined on 07-27-2006, 8:42 PM
    • Posts 18

    I've been playing around with Blinq today and everything was working fine until I decided to add a few more relationships in my database and then rerun blinq. Now when ever I try to update a record in any of the tables I get the ROW NOT FOUND OR CHANGED error. I realize there is a way to turn off the optimistic concurrency check, but I'm just wondering why it's necessary and why it suddenly occured after adding some simple relationships.

    Just trying to understand the process a little better. Thanks.

    My stack trace is below:

    OptimisticConcurrencyException: Row not found or changed.]
       System.Data.DLinq.ChangeProcessor.ThrowOptimisticConcurrencyException(List`1 failedUpdates, Int32 totalUpdatesAttempted) +171
       System.Data.DLinq.ChangeProcessor.SubmitChanges(ConflictMode failureMode) +522
       System.Data.DLinq.DataContext.SubmitChanges(ConflictMode failureMode) +229
       System.Data.DLinq.DataContext.SubmitChanges() +6
       TblOffice.Update(TblOffice original_x, TblOffice x) in c:\inetpub\wwwroot\TL\App_Code\StaticMethods.vb:462

    [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.Web.UI.WebControls.ObjectDataSourceView.InvokeMethod(ObjectDataSourceMethod method, Boolean disposeInstance, Object& instance) +482
       System.Web.UI.WebControls.ObjectDataSourceView.InvokeMethod(ObjectDataSourceMethod method) +38
       System.Web.UI.WebControls.ObjectDataSourceView.ExecuteUpdate(IDictionary keys, IDictionary values, IDictionary oldValues) +2573
       System.Web.UI.DataSourceView.Update(IDictionary keys, IDictionary values, IDictionary oldValues, DataSourceViewOperationCallback callback) +78
       System.Web.UI.WebControls.GridView.HandleUpdate(GridViewRow row, Int32 rowIndex, Boolean causesValidation) +1215
       System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +858
       System.Web.UI.WebControls.GridView.OnBubbleEvent(Object source, EventArgs e) +95
       System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
       System.Web.UI.WebControls.GridViewRow.OnBubbleEvent(Object source, EventArgs e) +117
       System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
       System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +115
       System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +163
       System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +174
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102

  • Re: Row not found or changed

    08-14-2006, 9:40 PM
    • Loading...
    • phuff
    • Joined on 06-11-2002, 12:39 PM
    • Redmond, WA
    • Posts 547
    • AspNetTeam

    Do you have a column of type DateTime with high precision?  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: Row not found or changed

    09-17-2006, 7:49 PM
    • Loading...
    • MEmam
    • Joined on 09-05-2006, 8:07 AM
    • Posts 14

    Hi,

    I don't know if you can help me to solve my problem. I am just writting to you because you had the same problem and also there was a solution from Polita to solve your problem. I am not sure if the reply from Polita was helpful to y

  • Re: Row not found or changed

    09-17-2006, 8:01 PM
    • Loading...
    • MEmam
    • Joined on 09-05-2006, 8:07 AM
    • Posts 14

    Hi,

    I don't know if you can help me to solve my problem. I am just writting to you because you had the same problem of not be able to update existing rpws and as well as there was a solution from Polita to solve your problem. I am not sure if the reply from Polita was helpful to you. I have tried the same solution to solve my problem but it did not help me.

    The second solution (Reply from Polita to solve your problem) was:

    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.

    The above paragraph asking me to see "Changing a Field’s Update Mode" to set the DateTime field as never participating in optimistic concurrency. But I don't know exactly where in my application I can get this optimistic concurrency property. so that I can change it. If you have any idea, please let me know.

     Also for your reference here is my error trace:

    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 57:       original_x.DateUpdated = x.DateUpdated;

    Line 58:       original_x.UpdatedBy = x.UpdatedBy;

    Line 59:       db.SubmitChanges();

    Line 60:       return 1;

    Line 61:     }


    Source File: c:\LinqWebsite\AffiliateBooks.aspx.cs    Line: 59

    Stack Trace:

     

    [OptimisticConcurrencyException: Row not found or changed.]

       System.Data.DLinq.ChangeProcessor.ThrowOptimisticConcurrencyException(List`1 failedUpdates, Int32 totalUpdatesAttempted) +171

       System.Data.DLinq.ChangeProcessor.SubmitChanges(ConflictMode failureMode) +521

       System.Data.DLinq.DataContext.SubmitChanges(ConflictMode failureMode) +229

       System.Data.DLinq.DataContext.SubmitChanges() +6

       AffiliateBooksPage.Update(AffiliateBook original_x, AffiliateBook x) in c:\LinqWebsite\AffiliateBooks.aspx.cs:59

     

    [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

       Microsoft.Web.UI.Controls.PageDataSourceView.InvokeMethod(PageDataSourceMethod method) +156

       Microsoft.Web.UI.Controls.PageDataSourceView.ExecuteUpdate(IDictionary keys, IDictionary values, IDictionary oldValues) +1420

       System.Web.UI.DataSourceView.Update(IDictionary keys, IDictionary values, IDictionary oldValues, DataSourceViewOperationCallback callback) +78

       System.Web.UI.WebControls.GridView.HandleUpdate(GridViewRow row, Int32 rowIndex, Boolean causesValidation) +1215

       System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +858

       System.Web.UI.WebControls.GridView.OnBubbleEvent(Object source, EventArgs e) +95

       System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35

       System.Web.UI.WebControls.GridViewRow.OnBubbleEvent(Object source, EventArgs e) +117

       System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35

       System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +115

       System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +163

       System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7

       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11

       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +174

       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102

  • Re: Row not found or changed

    09-18-2006, 5:33 PM
    • Loading...
    • cankersore
    • Joined on 07-27-2006, 8:42 PM
    • Posts 18

    Actually Polita's answer was very helpful. The document that she points you to has all the answers, but basically, in you App_code folder you'll have a .vb or .cs file named after your database. In there is a long list of database properties, associates and such. You need to find any potential problem columns (dates in my case) and change (or add) the updatecheck field to the top of the property.

    In the file look for something like this

    <Column(Name:="lastUpdatedDate", Storage:="_LastUpdatedDate", DbType:="DateTime", DataObjectField(False, False, True)>

    and add this to it

    UpdateCheck:=System.Data.DLinq.UpdateCheck.Never

    so it reads

    <Column(Name:="lastUpdatedDate", Storage:="_LastUpdatedDate", DbType:="DateTime", UpdateCheck:=System.Data.DLinq.UpdateCheck.Never), DataObjectField(False, False, True)>

    But before you do anything read the document Polita points you to. It's been a little while since I played with this and don't want to give you false information.

    Hope that helps.

  • Re: Row not found or changed

    09-19-2006, 4:59 AM
    • Loading...
    • MEmam
    • Joined on 09-05-2006, 8:07 AM
    • Posts 14

    Thanks very much for your quick reply. That was really helpful. Though your code help me to sort out the problem partially, I have figure a BUG in the BLINQ.

     Blinq does not work with timestamp in the database. So, I had to remove "IsVersion=true" from the code. Finally it works for me.

    The code before:

    [Column(Storage="_SSWTimestamp", DBType="rowversion NOT NULL", IsVersion=true]

    After:

    [Column(Storage="_DateCreated", DBType="DateTime NOT NULL", UpdateCheck=System.Data.DLinq.UpdateCheck.Never)]

     

    The reason could be:

    Though, Blinq correctly identify the timestamp as a version field, but asp.net datasource does not support byte array serialization.

    As a result, the timestamp value is null during post back, and fails the concurrency checking.

    Thanks again guys.

  • Re: Row not found or changed

    09-25-2006, 10:41 AM
    • Loading...
    • marcv67
    • Joined on 09-25-2006, 2:06 PM
    • Posts 1

    Hello,

    I have found another instance where this problem occurs (on any type of column).  In the ObjectDataSource, when a column's Visible property is set to false, the value it gets when the BO is created seems to be default(Type).  Just to see if that was the problem, I set the column's value in the Updating event.  The problem was still there.  For the update to work, I either have to set the column visible or set the UpdateCheck's column attribute to Never.  I chose the latter in my case.

    Why does a column get a value of default(Type) when it is not visible in the GridView (when the BO is created)?  It should be set to the original record's field value.

    BTW, I really like Blinq, thanks !!

  • Re: Row not found or changed

    09-25-2006, 12:52 PM
    • Loading...
    • phuff
    • Joined on 06-11-2002, 12:39 PM
    • Redmond, WA
    • Posts 547
    • AspNetTeam
    Marc, as you've found, setting Visible to false on a column in the GridView is problematic for Blinq.  The best way to remove a column from being displayed in the GridView is to set the column to not participate in optimistic concurrency.  There are instructions in the readme on how to do this.
    Polita Paulus

    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: Row not found or changed

    10-26-2006, 5:19 AM

    Polita,

    What Marc has found with updating (and I know about the fix there) I found the same with deleting, making columns invisible (and only some at that) break the delete as I assume its expecting all the values back to check before deleting. How do I get around this ?

    Thanks

    Zeid

    BTW Thanks for Blinq....

     

  • Re: Row not found or changed

    10-26-2006, 1:26 PM
    • Loading...
    • phuff
    • Joined on 06-11-2002, 12:39 PM
    • Redmond, WA
    • Posts 547
    • AspNetTeam
    The best way to remove a column from being displayed in the GridView is to set the column to not participate in optimistic concurrency.  There are instructions in the readme on how to do this.
    Polita Paulus

    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: Row not found or changed

    10-27-2006, 11:37 AM

     

    Polita,

    Thanks, but its not that - best way to explain is with a blinq website pointing at the northwind database.

    If you go to the orderdetails page. Working with Quantity, Discount or Unit Price,  try to delete one column at a time, you will find the the delete operation stops working with the "You have specified that your delete method compares all values on ObjectDataSource 'OrderDetailsDataSource', but the dictionary passed in for oldValues is empty.  Pass in a valid dictionary for delete or change your mode to OverwriteChanges", once these three have all been set to "visible=false" within the grid control.

    I have done this in any order and still the same result.

    Adding UpdateCheck=System.Data.DLinq.UpdateCheck.Never has no discernable affect. If say any one or two of the three colums are visible the delete operation works.

    Going to the ObectDataSource and setting it to OverwriteChanges makes it start working - however is this the only way to make delete operations work when you want to make certain fields invisible on the grid?.

    The question I have I guess is why is it working in this way.... 

    Thanks

     

    Zeid

     

  • Re: Row not found or changed

    11-06-2006, 6:07 PM
    • Loading...
    • MEmam
    • Joined on 09-05-2006, 8:07 AM
    • Posts 14

    Hi there,

    I don't know if you can help me with this one. Like update now I am having problem with inserting new rows into the database. It throws me the below error.

    I am using timestamp in my database.  

    It would be a great pleasure if any help. thanks 

    memam 

    ERROR msg:

    Cannot insert an explicit value into a timestamp column. Use INSERT with a column list to exclude the timestamp column, or insert a DEFAULT into the timestamp column.

    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.SqlClient.SqlException: Cannot insert an explicit value into a timestamp column. Use INSERT with a column list to exclude the timestamp column, or insert a DEFAULT into the timestamp column.

    Source Error:

    Line 16:       Dim db = CreateDataContext()
    Line 17:       db.AffiliateBooks.Add(x)
    Line 18:       db.SubmitChanges()
    Line 19:       Return 1
    Line 20:     End Function

    Source File: C:\DataEmamOddin\ProjectsTfs\SSW.Diagnostics\trunk\WebUI.Admin\NewAffiliateBook.aspx.vb    Line: 18

    Stack Trace:

    [SqlException (0x80131904): Cannot insert an explicit value into a timestamp column. Use INSERT with a column list to exclude the timestamp column, or insert a DEFAULT into the timestamp column.]
       System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +95
       System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +82
       System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +346
       System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +3244
       System.Data.SqlClient.SqlDataReader.ConsumeMetaData() +52
       System.Data.SqlClient.SqlDataReader.get_MetaData() +130
       System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +371
       System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +1121
       System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +334
       System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) +45
       System.Data.SqlClient.SqlCommand.ExecuteReader(Comm