在传递带有已修改行的DataRow集合时,Update需要有效的UpdateCommand。 [英] Update requires a valid UpdateCommand when passed DataRow collection with modified rows.

查看:87
本文介绍了在传递带有已修改行的DataRow集合时,Update需要有效的UpdateCommand。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

System.InvalidOperationException未处理

Message = Update在传递带有修改行的DataRow集合时需要有效的UpdateCommand。

Source = System.Data

StackTrace:

在System.Data.Common.DbDataAdapter.UpdatedRowStatusErrors(RowUpdatedEventArgs rowUpdatedEvent,BatchCommandInfo [] batchCommands,Int32 commandCount)

在System.Data.Common.DbDataAdapter .UpdatedRowStatus(RowUpdatedEventArgs rowUpdatedEvent,BatchCommandInfo [] batchCommands,Int32 commandCount)

在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 WindowsApplication2.f_libraryDataSet1TableAdapters c中的.add_bookTableAdapter.Update(add_bookDataTable dataTable) :\ Users \hend \Desktop \New folder(2)\New folder \final \ WindowsApplication2 \f_libraryDataSet1.Designer.cs:line 62418

at WindowsApplication2.add_book。 book_careBindingNavigatorSaveItem_Click(Object sender,EventArgs e)在c:\ Users \ hend \Desktop \New文件夹中(2)\New folder \final \ WindowsApplication2 \ add_book.cs:第33行

at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key,EventArgs e)

at System.Windows.Forms.ToolStripButton.OnClick(EventArgs e)

在System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)

在System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)

在System.Windows.Forms .ToolStripItem.FireEventInteractive(EventArgs e,ToolStripItemEventType符合)

在System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e,ToolStripItemEventType met)

at Syste m.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)

在System.Windows.Forms.Control.WmMouseUp(Message&m,MouseButtons按钮,Int32点击)

at System.Windows.Forms.Control.WndProc(Message&m)

在System.Windows.Forms.ScrollableControl.WndProc(Message&m)

在System.Windows.Forms。 ToolStrip.WndProc(Message&m)

在System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&m)

在System.Windows.Forms.Control.ControlNativeWindow。 WndProc(Message&m)

在System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd,Int32 msg,IntPtr wparam,IntPtr lparam)

在System.Windows.Forms .UnsafeNativeMethods.DispatchMessageW(MSG&msg)

在System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID,Int32 reason,Int32 pvLoopData)

在System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason,ApplicationContext context)

在System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason,ApplicationContext context)
System.Windows.Forms.Application.Run(Form mainForm)

$ c $ b at WindowsApplication2.Program.Main()in c:\ Users \ hend \Desktop \ New文件夹(2)\ new文件夹\final \ WindowsApplication2 \Program.cs:第17行

在System.AppDomain._nExecuteAssembly(程序集,String [] args)
$ b System.AppDomain.nExecuteAssembly上的$ b(程序集程序集,String [] args)

at System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)

at System。 System.Runtime.Hosting.ApplicationActivator.CreateInstance中的Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()

(ActivationContext activationContext,String [] activationCustomData)

在System.Activator.CreateInstance(ActivationContext activationContext)

在Microsoft。 System.Threading.ThreadHelper.ThreadStart_Context(对象状态)
在System.Threading.ExecutionContext.Run(ExecutionContext executionContext,ContextCallback)中的
.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()

回调,对象状态)

at System.Threading.ThreadHelper.ThreadStart()

InnerException:

System.InvalidOperationException was unhandled
Message=Update requires a valid UpdateCommand when passed DataRow collection with modified rows.
Source=System.Data
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 WindowsApplication2.f_libraryDataSet1TableAdapters.add_bookTableAdapter.Update(add_bookDataTable dataTable) in c:\Users\hend\Desktop\New folder (2)\New folder\final\WindowsApplication2\f_libraryDataSet1.Designer.cs:line 62418
at WindowsApplication2.add_book.book_careBindingNavigatorSaveItem_Click(Object sender, EventArgs e) in c:\Users\hend\Desktop\New folder (2)\New folder\final\WindowsApplication2\add_book.cs:line 33
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(Form mainForm)
at WindowsApplication2.Program.Main() in c:\Users\hend\Desktop\New folder (2)\New folder\final\WindowsApplication2\Program.cs:line 17
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)
at System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()
at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext)
at System.Activator.CreateInstance(ActivationContext activationContext)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
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:

推荐答案

这个函数



this in the function

private void book_careBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            this.Validate();
            this.addbookBindingSource.EndEdit();
            this.add_bookTableAdapter.Update(f_libraryDataSet1.add_book);

        }


这篇关于在传递带有已修改行的DataRow集合时,Update需要有效的UpdateCommand。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆