Concurrency error deleting record with vs 2008 generated code

J

John

Hi

I have a very simple db app that was created by dragging a couple of fields
onto a windows form. No additional code was added. The problem is that app
gives a concurrency error while deleting a record even though no other user
has access to the app.

Steps to create problem

1. Create an access table Clients with only two fields; ID Auto number and
Company: Text(50).

2. Make a connection to the access db in vs2008 and add the data source to
the connection.

3. From data source, drag the fields ID and Company onto a windows form.
This will create the binding source, binding navigator etc.

4. Click on new (+) icon on toolbar to create a new record.

5. Type XYZ in Company text field and click on Save (disk) icon on toolbar
to save the record.

6. Click on Delete (x) icon to delete the record and then Save icon on
toolbar to save the record deletion.

At this point the error is generated with the stack trace given at the end
below.

What is the problem and how can I fix it?

Thanks

Regards


System.Data.DBConcurrencyException was unhandled
Message="Concurrency violation: the DeleteCommand affected 0 of the expected
1 records."
RowCount=1
Source="Test"
StackTrace:
at Test.DataDataSetTableAdapters.TableAdapterManager.UpdateAll(DataDataSet
dataSet) in C:\Test\DataDataSet.Designer.vb:line 1171 at
Test.Form1.ClientsBindingNavigatorSaveItem_Click(Object sender, EventArgs e)
in C:\Test\Form1.vb:line 6 at
System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e) at
System.Windows.Forms.ToolStripButton.OnClick(EventArgs e) at
System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e) at
System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e) at
System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e,
ToolStripItemEventType met) at
System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e,
ToolStripItemEventType met) at
System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea) at
System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button,
Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at
System.Windows.Forms.ScrollableControl.WndProc(Message& m) at
System.Windows.Forms.ToolStrip.WndProc(Message& m) at
System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at
System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at
System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam) at
System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) at
System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData) at
System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context) at
System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason,
ApplicationContext context) at
System.Windows.Forms.Application.Run(ApplicationContext context) at
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[]
commandLine) at Test.My.MyApplication.Main(String[] Args) in
17d14f5c-a337-4978-8281-53493378c1071.vb:line 81 at
System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) at
System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence
assemblySecurity, String[] args) at
Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at
System.Threading.ThreadHelper.ThreadStart_Context(Object state) at
System.Threading.ExecutionContext.Run(ExecutionContext executionContext,
ContextCallback callback, Object state) at
System.Threading.ThreadHelper.ThreadStart()
InnerException:
 
T

Terry

At the point that you go to delete the record, do you actually have the Id
assigned by access? I don't use Access, so I am not sure how to get Id
assigned, but I am guessing that is what the problem is.
--
Terry


John said:
Hi

I have a very simple db app that was created by dragging a couple of fields
onto a windows form. No additional code was added. The problem is that app
gives a concurrency error while deleting a record even though no other user
has access to the app.

Steps to create problem

1. Create an access table Clients with only two fields; ID Auto number and
Company: Text(50).

2. Make a connection to the access db in vs2008 and add the data source to
the connection.

3. From data source, drag the fields ID and Company onto a windows form.
This will create the binding source, binding navigator etc.

4. Click on new (+) icon on toolbar to create a new record.

5. Type XYZ in Company text field and click on Save (disk) icon on toolbar
to save the record.

6. Click on Delete (x) icon to delete the record and then Save icon on
toolbar to save the record deletion.

At this point the error is generated with the stack trace given at the end
below.

What is the problem and how can I fix it?

Thanks

Regards


System.Data.DBConcurrencyException was unhandled
Message="Concurrency violation: the DeleteCommand affected 0 of the expected
1 records."
RowCount=1
Source="Test"
StackTrace:
at Test.DataDataSetTableAdapters.TableAdapterManager.UpdateAll(DataDataSet
dataSet) in C:\Test\DataDataSet.Designer.vb:line 1171 at
Test.Form1.ClientsBindingNavigatorSaveItem_Click(Object sender, EventArgs e)
in C:\Test\Form1.vb:line 6 at
System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e) at
System.Windows.Forms.ToolStripButton.OnClick(EventArgs e) at
System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e) at
System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e) at
System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e,
ToolStripItemEventType met) at
System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e,
ToolStripItemEventType met) at
System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea) at
System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button,
Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at
System.Windows.Forms.ScrollableControl.WndProc(Message& m) at
System.Windows.Forms.ToolStrip.WndProc(Message& m) at
System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at
System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at
System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam) at
System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) at
System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData) at
System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context) at
System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason,
ApplicationContext context) at
System.Windows.Forms.Application.Run(ApplicationContext context) at
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[]
commandLine) at Test.My.MyApplication.Main(String[] Args) in
17d14f5c-a337-4978-8281-53493378c1071.vb:line 81 at
System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) at
System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence
assemblySecurity, String[] args) at
Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at
System.Threading.ThreadHelper.ThreadStart_Context(Object state) at
System.Threading.ExecutionContext.Run(ExecutionContext executionContext,
ContextCallback callback, Object state) at
System.Threading.ThreadHelper.ThreadStart()
InnerException:
 
J

John

id is auto number so it comes automatically from the underlying db engine
(jet I presume).

Terry said:
At the point that you go to delete the record, do you actually have the Id
assigned by access? I don't use Access, so I am not sure how to get Id
assigned, but I am guessing that is what the problem is.
--
Terry


John said:
Hi

I have a very simple db app that was created by dragging a couple of
fields
onto a windows form. No additional code was added. The problem is that
app
gives a concurrency error while deleting a record even though no other
user
has access to the app.

Steps to create problem

1. Create an access table Clients with only two fields; ID Auto number
and
Company: Text(50).

2. Make a connection to the access db in vs2008 and add the data source
to
the connection.

3. From data source, drag the fields ID and Company onto a windows form.
This will create the binding source, binding navigator etc.

4. Click on new (+) icon on toolbar to create a new record.

5. Type XYZ in Company text field and click on Save (disk) icon on
toolbar
to save the record.

6. Click on Delete (x) icon to delete the record and then Save icon on
toolbar to save the record deletion.

At this point the error is generated with the stack trace given at the
end
below.

What is the problem and how can I fix it?

Thanks

Regards


System.Data.DBConcurrencyException was unhandled
Message="Concurrency violation: the DeleteCommand affected 0 of the
expected
1 records."
RowCount=1
Source="Test"
StackTrace:
at
Test.DataDataSetTableAdapters.TableAdapterManager.UpdateAll(DataDataSet
dataSet) in C:\Test\DataDataSet.Designer.vb:line 1171 at
Test.Form1.ClientsBindingNavigatorSaveItem_Click(Object sender, EventArgs
e)
in C:\Test\Form1.vb:line 6 at
System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e) at
System.Windows.Forms.ToolStripButton.OnClick(EventArgs e) at
System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e) at
System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e) at
System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e,
ToolStripItemEventType met) at
System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e,
ToolStripItemEventType met) at
System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea) at
System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button,
Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at
System.Windows.Forms.ScrollableControl.WndProc(Message& m) at
System.Windows.Forms.ToolStrip.WndProc(Message& m) at
System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at
System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at
System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32
msg,
IntPtr wparam, IntPtr lparam) at
System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) at
System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData) at
System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context) at
System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32
reason,
ApplicationContext context) at
System.Windows.Forms.Application.Run(ApplicationContext context) at
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[]
commandLine) at Test.My.MyApplication.Main(String[] Args) in
17d14f5c-a337-4978-8281-53493378c1071.vb:line 81 at
System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) at
System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence
assemblySecurity, String[] args) at
Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at
System.Threading.ThreadHelper.ThreadStart_Context(Object state) at
System.Threading.ExecutionContext.Run(ExecutionContext executionContext,
ContextCallback callback, Object state) at
System.Threading.ThreadHelper.ThreadStart()
InnerException:
 
T

Terry

Yes, but you need to get the number assigned by jet into the record in you
dataset. The Table adapter will not do this automtically (at least that was
true the last time I looked). But by setting a breakpoint when you are
deleting you will *know* if you have an Id assigned to the record - I bet the
answer is No! I just typed "Access Identity" into the search box on this
page and found a discussion on the same subject. Try it and see what it says.
--
Terry


John said:
id is auto number so it comes automatically from the underlying db engine
(jet I presume).

Terry said:
At the point that you go to delete the record, do you actually have the Id
assigned by access? I don't use Access, so I am not sure how to get Id
assigned, but I am guessing that is what the problem is.
--
Terry


John said:
Hi

I have a very simple db app that was created by dragging a couple of
fields
onto a windows form. No additional code was added. The problem is that
app
gives a concurrency error while deleting a record even though no other
user
has access to the app.

Steps to create problem

1. Create an access table Clients with only two fields; ID Auto number
and
Company: Text(50).

2. Make a connection to the access db in vs2008 and add the data source
to
the connection.

3. From data source, drag the fields ID and Company onto a windows form.
This will create the binding source, binding navigator etc.

4. Click on new (+) icon on toolbar to create a new record.

5. Type XYZ in Company text field and click on Save (disk) icon on
toolbar
to save the record.

6. Click on Delete (x) icon to delete the record and then Save icon on
toolbar to save the record deletion.

At this point the error is generated with the stack trace given at the
end
below.

What is the problem and how can I fix it?

Thanks

Regards


System.Data.DBConcurrencyException was unhandled
Message="Concurrency violation: the DeleteCommand affected 0 of the
expected
1 records."
RowCount=1
Source="Test"
StackTrace:
at
Test.DataDataSetTableAdapters.TableAdapterManager.UpdateAll(DataDataSet
dataSet) in C:\Test\DataDataSet.Designer.vb:line 1171 at
Test.Form1.ClientsBindingNavigatorSaveItem_Click(Object sender, EventArgs
e)
in C:\Test\Form1.vb:line 6 at
System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e) at
System.Windows.Forms.ToolStripButton.OnClick(EventArgs e) at
System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e) at
System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e) at
System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e,
ToolStripItemEventType met) at
System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e,
ToolStripItemEventType met) at
System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea) at
System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button,
Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at
System.Windows.Forms.ScrollableControl.WndProc(Message& m) at
System.Windows.Forms.ToolStrip.WndProc(Message& m) at
System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at
System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at
System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32
msg,
IntPtr wparam, IntPtr lparam) at
System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) at
System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData) at
System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context) at
System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32
reason,
ApplicationContext context) at
System.Windows.Forms.Application.Run(ApplicationContext context) at
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[]
commandLine) at Test.My.MyApplication.Main(String[] Args) in
17d14f5c-a337-4978-8281-53493378c1071.vb:line 81 at
System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) at
System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence
assemblySecurity, String[] args) at
Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at
System.Threading.ThreadHelper.ThreadStart_Context(Object state) at
System.Threading.ExecutionContext.Run(ExecutionContext executionContext,
ContextCallback callback, Object state) at
System.Threading.ThreadHelper.ThreadStart()
InnerException:
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top