Home All Groups Group Topic Archive Search About

The record cannot be deleted or changed because table

Author
16 Feb 2007 3:47 PM
nkw
I have two tables in Access obligor and Collateral, and collateral has
foreign key reference to obligor.

I created a winform to edit obligor. i tried to modify a none primary key
column and got the following error.

                this.obligorBindingSource.EndEdit();
                this.obligorTableAdapter.Update(this.ldgDataSet.Obligor);

the error shouldn't occur since no PK is modified?


System.Data.OleDb.OleDbException was unhandled
  Message="The record cannot be deleted or changed because table
'Collateral' includes related records."
  Source="Microsoft JET Database Engine"
  ErrorCode=-2147467259
  StackTrace:
       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(DataTable dataTable)
       at
LGD.ldgDataSetTableAdapters.ObligorTableAdapter.Update(ObligorDataTable
dataTable) in C:\Working\crdweb\LGD\ldgDataSet.Designer.cs:line 16984
       at LGD.Obligor.btnSave_Click(Object sender, EventArgs e) in
C:\Working\crdweb\LGD\Obligor.cs:line 37
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       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 LGD.Program.Main() in C:\Working\crdweb\LGD\Program.cs:line 17
       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()

Author
16 Feb 2007 4:27 PM
nkw
Probably the ADO.Net always rewrite every column if it's not modified? So we
must change all foreign key contrait in the MDB file to cascade update?
Sounds not so good since sometime i don't want the master key being
modified...

Show quote
"nkw" wrote:

> I have two tables in Access obligor and Collateral, and collateral has
> foreign key reference to obligor.
>
> I created a winform to edit obligor. i tried to modify a none primary key
> column and got the following error.
>
>                 this.obligorBindingSource.EndEdit();
>                 this.obligorTableAdapter.Update(this.ldgDataSet.Obligor);
>
> the error shouldn't occur since no PK is modified?
>
>
> System.Data.OleDb.OleDbException was unhandled
>   Message="The record cannot be deleted or changed because table
> 'Collateral' includes related records."
>   Source="Microsoft JET Database Engine"
>   ErrorCode=-2147467259
>   StackTrace:
>        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(DataTable dataTable)
>        at
> LGD.ldgDataSetTableAdapters.ObligorTableAdapter.Update(ObligorDataTable
> dataTable) in C:\Working\crdweb\LGD\ldgDataSet.Designer.cs:line 16984
>        at LGD.Obligor.btnSave_Click(Object sender, EventArgs e) in
> C:\Working\crdweb\LGD\Obligor.cs:line 37
>        at System.Windows.Forms.Control.OnClick(EventArgs e)
>        at System.Windows.Forms.Button.OnClick(EventArgs e)
>        at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
>        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 LGD.Program.Main() in C:\Working\crdweb\LGD\Program.cs:line 17
>        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()
>
Author
16 Feb 2007 6:30 PM
RobinS
You are probably right. You could write your own update routine. I don't
know if you can modify the UpdateCommand that is attached to a strongly
typed dataset, but you could try.

Robin S.
-----------------------------------------
Show quote
"nkw" <n**@discussions.microsoft.com> wrote in message
news:4221D38A-E8E6-4D6A-BC4A-33FD3BB3D1A4@microsoft.com...
> Probably the ADO.Net always rewrite every column if it's not modified? So
> we
> must change all foreign key contrait in the MDB file to cascade update?
> Sounds not so good since sometime i don't want the master key being
> modified...
>
> "nkw" wrote:
>
>> I have two tables in Access obligor and Collateral, and collateral has
>> foreign key reference to obligor.
>>
>> I created a winform to edit obligor. i tried to modify a none primary
>> key
>> column and got the following error.
>>
>>                 this.obligorBindingSource.EndEdit();
>>
>> this.obligorTableAdapter.Update(this.ldgDataSet.Obligor);
>>
>> the error shouldn't occur since no PK is modified?
>>
>>
>> System.Data.OleDb.OleDbException was unhandled
>>   Message="The record cannot be deleted or changed because table
>> 'Collateral' includes related records."
>>   Source="Microsoft JET Database Engine"
>>   ErrorCode=-2147467259
>>   StackTrace:
>>        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(DataTable dataTable)
>>        at
>> LGD.ldgDataSetTableAdapters.ObligorTableAdapter.Update(ObligorDataTable
>> dataTable) in C:\Working\crdweb\LGD\ldgDataSet.Designer.cs:line 16984
>>        at LGD.Obligor.btnSave_Click(Object sender, EventArgs e) in
>> C:\Working\crdweb\LGD\Obligor.cs:line 37
>>        at System.Windows.Forms.Control.OnClick(EventArgs e)
>>        at System.Windows.Forms.Button.OnClick(EventArgs e)
>>        at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
>>        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 LGD.Program.Main() in C:\Working\crdweb\LGD\Program.cs:line 17
>>        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()
>>
Author
16 Feb 2007 8:50 PM
nkw
I changed the updatecommand query to
update
set nonPKcolumns=?, .....
where PKcolumns=?

Test run (Execute Query in the DataSet design page) works well and updated
the changes.

However it doesn't save the changes in the program:

            if (this.Validate())
            {
                this.obligorBindingSource.EndEdit();
                this.obligorTableAdapter.Update(this.ldgDataSet.Obligor);
            }

Did I missed anything?

Show quote
"RobinS" wrote:

> You are probably right. You could write your own update routine. I don't
> know if you can modify the UpdateCommand that is attached to a strongly
> typed dataset, but you could try.
>
> Robin S.
> -----------------------------------------
> "nkw" <n**@discussions.microsoft.com> wrote in message
> news:4221D38A-E8E6-4D6A-BC4A-33FD3BB3D1A4@microsoft.com...
> > Probably the ADO.Net always rewrite every column if it's not modified? So
> > we
> > must change all foreign key contrait in the MDB file to cascade update?
> > Sounds not so good since sometime i don't want the master key being
> > modified...
> >
> > "nkw" wrote:
> >
> >> I have two tables in Access obligor and Collateral, and collateral has
> >> foreign key reference to obligor.
> >>
> >> I created a winform to edit obligor. i tried to modify a none primary
> >> key
> >> column and got the following error.
> >>
> >>                 this.obligorBindingSource.EndEdit();
> >>
> >> this.obligorTableAdapter.Update(this.ldgDataSet.Obligor);
> >>
> >> the error shouldn't occur since no PK is modified?
> >>
> >>
> >> System.Data.OleDb.OleDbException was unhandled
> >>   Message="The record cannot be deleted or changed because table
> >> 'Collateral' includes related records."
> >>   Source="Microsoft JET Database Engine"
> >>   ErrorCode=-2147467259
> >>   StackTrace:
> >>        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(DataTable dataTable)
> >>        at
> >> LGD.ldgDataSetTableAdapters.ObligorTableAdapter.Update(ObligorDataTable
> >> dataTable) in C:\Working\crdweb\LGD\ldgDataSet.Designer.cs:line 16984
> >>        at LGD.Obligor.btnSave_Click(Object sender, EventArgs e) in
> >> C:\Working\crdweb\LGD\Obligor.cs:line 37
> >>        at System.Windows.Forms.Control.OnClick(EventArgs e)
> >>        at System.Windows.Forms.Button.OnClick(EventArgs e)
> >>        at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
> >>        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 LGD.Program.Main() in C:\Working\crdweb\LGD\Program.cs:line 17
> >>        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()
> >>
>
>
>
Author
16 Feb 2007 9:18 PM
nkw
Nevermind, my bad, I have "copy always" for the mdb file...

Show quote
"nkw" wrote:

> I changed the updatecommand query to
> update
> set nonPKcolumns=?, .....
> where PKcolumns=?
>
> Test run (Execute Query in the DataSet design page) works well and updated
> the changes.
>
> However it doesn't save the changes in the program:
>
>             if (this.Validate())
>             {
>                 this.obligorBindingSource.EndEdit();
>                 this.obligorTableAdapter.Update(this.ldgDataSet.Obligor);
>             }
>
> Did I missed anything?
>
> "RobinS" wrote:
>
> > You are probably right. You could write your own update routine. I don't
> > know if you can modify the UpdateCommand that is attached to a strongly
> > typed dataset, but you could try.
> >
> > Robin S.
> > -----------------------------------------
> > "nkw" <n**@discussions.microsoft.com> wrote in message
> > news:4221D38A-E8E6-4D6A-BC4A-33FD3BB3D1A4@microsoft.com...
> > > Probably the ADO.Net always rewrite every column if it's not modified? So
> > > we
> > > must change all foreign key contrait in the MDB file to cascade update?
> > > Sounds not so good since sometime i don't want the master key being
> > > modified...
> > >
> > > "nkw" wrote:
> > >
> > >> I have two tables in Access obligor and Collateral, and collateral has
> > >> foreign key reference to obligor.
> > >>
> > >> I created a winform to edit obligor. i tried to modify a none primary
> > >> key
> > >> column and got the following error.
> > >>
> > >>                 this.obligorBindingSource.EndEdit();
> > >>
> > >> this.obligorTableAdapter.Update(this.ldgDataSet.Obligor);
> > >>
> > >> the error shouldn't occur since no PK is modified?
> > >>
> > >>
> > >> System.Data.OleDb.OleDbException was unhandled
> > >>   Message="The record cannot be deleted or changed because table
> > >> 'Collateral' includes related records."
> > >>   Source="Microsoft JET Database Engine"
> > >>   ErrorCode=-2147467259
> > >>   StackTrace:
> > >>        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(DataTable dataTable)
> > >>        at
> > >> LGD.ldgDataSetTableAdapters.ObligorTableAdapter.Update(ObligorDataTable
> > >> dataTable) in C:\Working\crdweb\LGD\ldgDataSet.Designer.cs:line 16984
> > >>        at LGD.Obligor.btnSave_Click(Object sender, EventArgs e) in
> > >> C:\Working\crdweb\LGD\Obligor.cs:line 37
> > >>        at System.Windows.Forms.Control.OnClick(EventArgs e)
> > >>        at System.Windows.Forms.Button.OnClick(EventArgs e)
> > >>        at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
> > >>        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 LGD.Program.Main() in C:\Working\crdweb\LGD\Program.cs:line 17
> > >>        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()
> > >>
> >
> >
> >
Author
16 Feb 2007 11:15 PM
RobinS
Thank goodness. I didn't know what else could be wrong. I'm glad it's
working for you now.

Robin S.
---------------------------------------
Show quote
"nkw" <n**@discussions.microsoft.com> wrote in message
news:694892FC-318C-4577-9141-452C4644121E@microsoft.com...
> Nevermind, my bad, I have "copy always" for the mdb file...
>
> "nkw" wrote:
>
>> I changed the updatecommand query to
>> update
>> set nonPKcolumns=?, .....
>> where PKcolumns=?
>>
>> Test run (Execute Query in the DataSet design page) works well and
>> updated
>> the changes.
>>
>> However it doesn't save the changes in the program:
>>
>>             if (this.Validate())
>>             {
>>                 this.obligorBindingSource.EndEdit();
>>
>> this.obligorTableAdapter.Update(this.ldgDataSet.Obligor);
>>             }
>>
>> Did I missed anything?
>>
>> "RobinS" wrote:
>>
>> > You are probably right. You could write your own update routine. I
>> > don't
>> > know if you can modify the UpdateCommand that is attached to a
>> > strongly
>> > typed dataset, but you could try.
>> >
>> > Robin S.
>> > -----------------------------------------
>> > "nkw" <n**@discussions.microsoft.com> wrote in message
>> > news:4221D38A-E8E6-4D6A-BC4A-33FD3BB3D1A4@microsoft.com...
>> > > Probably the ADO.Net always rewrite every column if it's not
>> > > modified? So
>> > > we
>> > > must change all foreign key contrait in the MDB file to cascade
>> > > update?
>> > > Sounds not so good since sometime i don't want the master key being
>> > > modified...
>> > >
>> > > "nkw" wrote:
>> > >
>> > >> I have two tables in Access obligor and Collateral, and collateral
>> > >> has
>> > >> foreign key reference to obligor.
>> > >>
>> > >> I created a winform to edit obligor. i tried to modify a none
>> > >> primary
>> > >> key
>> > >> column and got the following error.
>> > >>
>> > >>                 this.obligorBindingSource.EndEdit();
>> > >>
>> > >> this.obligorTableAdapter.Update(this.ldgDataSet.Obligor);
>> > >>
>> > >> the error shouldn't occur since no PK is modified?
>> > >>
>> > >>
>> > >> System.Data.OleDb.OleDbException was unhandled
>> > >>   Message="The record cannot be deleted or changed because table
>> > >> 'Collateral' includes related records."
>> > >>   Source="Microsoft JET Database Engine"
>> > >>   ErrorCode=-2147467259
>> > >>   StackTrace:
>> > >>        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(DataTable
>> > >> dataTable)
>> > >>        at
>> > >> LGD.ldgDataSetTableAdapters.ObligorTableAdapter.Update(ObligorDataTable
>> > >> dataTable) in C:\Working\crdweb\LGD\ldgDataSet.Designer.cs:line
>> > >> 16984
>> > >>        at LGD.Obligor.btnSave_Click(Object sender, EventArgs e) in
>> > >> C:\Working\crdweb\LGD\Obligor.cs:line 37
>> > >>        at System.Windows.Forms.Control.OnClick(EventArgs e)
>> > >>        at System.Windows.Forms.Button.OnClick(EventArgs e)
>> > >>        at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs
>> > >> mevent)
>> > >>        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 LGD.Program.Main() in
>> > >> C:\Working\crdweb\LGD\Program.cs:line 17
>> > >>        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()
>> > >>
>> >
>> >
>> >

AddThis Social Bookmark Button