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
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:
oChange the precision displayed by the
BoundField object by setting
DataFormatString="{0:o}",
HtmlEncode=false, and
ApplyFormatInEditMode=true.
oDesignate 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.
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
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.
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.
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.
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.
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.
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.
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 ?
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.
cankersore
Member
32 Points
19 Posts
Row not found or changed
Aug 11, 2006 08:34 PM|LINK
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
phuff
Contributor
2700 Points
547 Posts
AspNetTeam
Re: Row not found or changed
Aug 15, 2006 01:40 AM|LINK
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.
This posting is provided "AS IS" with no warranties, and confers no rights.
MEmam
Member
45 Points
14 Posts
Re: Row not found or changed
Sep 17, 2006 11:49 PM|LINK
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
MEmam
Member
45 Points
14 Posts
Re: Row not found or changed
Sep 18, 2006 12:01 AM|LINK
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
cankersore
Member
32 Points
19 Posts
Re: Row not found or changed
Sep 18, 2006 09:33 PM|LINK
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.
MEmam
Member
45 Points
14 Posts
Re: Row not found or changed
Sep 19, 2006 08:59 AM|LINK
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.
Problem with updating records
marcv67
Member
5 Points
1 Post
Re: Row not found or changed
Sep 25, 2006 02:41 PM|LINK
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 !!
Blinq Problem with updating records
phuff
Contributor
2700 Points
547 Posts
AspNetTeam
Re: Row not found or changed
Sep 25, 2006 04:52 PM|LINK
This posting is provided "AS IS" with no warranties, and confers no rights.
The Developm...
Member
85 Points
17 Posts
Re: Row not found or changed
Oct 26, 2006 09:19 AM|LINK
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....
LINQ Blinq Problem with updating records
phuff
Contributor
2700 Points
547 Posts
AspNetTeam
Re: Row not found or changed
Oct 26, 2006 05:26 PM|LINK
This posting is provided "AS IS" with no warranties, and confers no rights.