General information
Category:
The Mere Mortals .NET Framework
Environment versions
Network:
Windows 2003 Server
Don't know if you ever solved this but I just watched a developer run into the problem. It occured because the table he was deleting had a foreign key constraint to another table.
Switching the order in which the objects were deleting (there were several) resolved the issue by removing the data in a way that didn't violate the constraint.
>>I have a very simple Business object that reads, write,delete and selects from a single table. When I try to delete a record I get
>>Concurrency violation: the DeleteCommand affected 0 of the expected 1 records.
>
>Can you describe what your form is doing? It seems unusual to get a concurrency violation when deleting. It looks like you are using an mmButtonDelete instance on your form. Have you specified a primary business object on your form or have you set the button's BindingSource property?
>
>
>The form adds, updates and delete data from a single table, it has two primary keys. I am using the base delete button. I have specified a primary business object.
>
>Public Sub New()
> Me.oSponsor = CType(Me.RegisterPrimaryBizObj(New Sponsor()), Sponsor)
> Me.oSponsor.DatabaseKey = "FRONTOFFICE"
> ' This call is required by the Windows Form Designer.
> InitializeComponent()
> Me.grdSponsor.AutoGenerateColumns = False
> ' Retrieve all employees
> Me.oSponsor.GetAllData()
> ' Specify the Navigation control
> Me.NavControl = Me.grdSponsor
> End Sub
>
>
>This the message I am getting
>
>Concurrency violation: the DeleteCommand affected 0 of the expected 1 records.
>
>Below is the stack trace
>
>at System.Data.Common.DbDataAdapter.UpdatedRowStatusErrors(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
> at System.Data.Common.DbDataAdapter.UpdatedRowStatus(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
> at System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping)
> at System.Data.Common.DbDataAdapter.UpdateFromDataTable(DataTable dataTable, DataTableMapping tableMapping)
> at System.Data.Common.DbDataAdapter.Update(DataSet dataSet, String srcTable)
> at OakLeaf.MM.Main.Data.mmDataAccessSql.SaveDataSet(DataSet ds, String tableName, String primaryKeyName, Boolean retrieveAutoIncrementPK, IDbDataAdapter dbAdapter)
> at OakLeaf.MM.Main.Business.mmBusinessObject.Delete(DataRow dr)
> at OakLeaf.MM.Main.Business.mmBusinessObject.Delete(DataRowView drView)
> at OakLeaf.MM.Main.Windows.Forms.mmBusinessForm.Delete(mmBusinessObject bizObj, DataRowView drView)
> at OakLeaf.MM.Main.Windows.Forms.mmBusinessForm.Delete(mmBusinessObject bizObj, String tableName)
> at OakLeaf.MM.Main.Windows.Forms.mmButtonHelper.DeleteHandler(Object button, String bindingSource, String bindingSourceMember, mmBaseBusinessObject& bizObj)
> at OakLeaf.MM.Main.Windows.Forms.mmButtonDelete.mmButtonDelete_Click(Object sender, EventArgs e)
> at System.Windows.Forms.Control.OnClick(EventArgs e)
> at System.Windows.Forms.Button.OnClick(EventArgs e)
> at System.Windows.Forms.Button.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.SendMessage(HandleRef hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
> at System.Windows.Forms.Control.SendMessage(Int32 msg, IntPtr wparam, IntPtr lparam)
> at System.Windows.Forms.Control.ReflectMessageInternal(IntPtr hWnd, Message& m)
> at System.Windows.Forms.Control.WmCommand(Message& m)
> at System.Windows.Forms.Control.WndProc(Message& m)
> at System.Windows.Forms.ScrollableControl.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.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
> at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
> at System.Windows.Forms.Control.DefWndProc(Message& m)
> at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
> at System.Windows.Forms.Control.WndProc(Message& m)
> at System.Windows.Forms.ButtonBase.WndProc(Message& m)
> at System.Windows.Forms.Button.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(Form mainForm)
> at ACELO.OSP.WINDOW.AppMainEntry.Main() in C:\OSP\Acelo.OSP.Window\Acelo.OSP.Window\Main.vb:line 52
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only