菜鸟问题:关于修改数据到数据库,出了点问题。。。

wsdydmw 2009-12-05 11:35:57
在保存按钮下执行下列语句
this.BindingContext[ds, "Courseinfo"].EndCurrentEdit();
sqlDataAdapter1.Update(ds, "Courseinfo");

[size=14px]在
sqlDataAdapter1.Update(ds, "Courseinfo");
出现异常为
[未处理 System.Exception
Message="System.InvalidOperationException: ExecuteReader: CommandText 属性尚未初始化\r\n 在 System.Data.Common.DbDataAdapter.UpdatedRowStatusErrors(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)\r\n 在 System.Data.Common.DbDataAdapter.UpdatedRowStatus(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)\r\n 在 System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping)\r\n 在 System.Data.Common.DbDataAdapter.UpdateFromDataTable(DataTable dataTable, DataTableMapping tableMapping)\r\n 在 System.Data.Common.DbDataAdapter.Update(DataSet dataSet, String srcTable)\r\n 在 EducationalAdmin.课程管理.CourseQueryForm.button3_Click(Object sender, EventArgs e) 位置 F:\\高级C#\\EducationalAdmin\\EducationalAdmin\\课程管理\\CourseQueryForm.cs:行号 83"
Source="EducationalAdmin"
StackTrace:
在 EducationalAdmin.课程管理.CourseQueryForm.button3_Click(Object sender, EventArgs e) 位置 F:\高级C#\EducationalAdmin\EducationalAdmin\课程管理\CourseQueryForm.cs:行号 87
在 System.Windows.Forms.Control.OnClick(EventArgs e)
在 System.Windows.Forms.Button.OnClick(EventArgs e)
在 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
在 System.Windows.Forms.Control.WndProc(Message& m)
在 System.Windows.Forms.ButtonBase.WndProc(Message& m)
在 System.Windows.Forms.Button.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.RunDialog(Form form)
在 System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
在 System.Windows.Forms.Form.ShowDialog()
在 EducationalAdmin.MainWindow.课程信息查询与删除ToolStripMenuItem_Click(Object sender, EventArgs e) 位置 F:\高级C#\EducationalAdmin\EducationalAdmin\MainWindow.cs:行号 39
在 System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
在 System.Windows.Forms.ToolStripMenuItem.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 met)
在 System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
在 System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
在 System.Windows.Forms.ToolStripDropDown.OnMouseUp(MouseEventArgs mea)
在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
在 System.Windows.Forms.Control.WndProc(Message& m)
在 System.Windows.Forms.ScrollableControl.WndProc(Message& m)
在 System.Windows.Forms.ToolStrip.WndProc(Message& m)
在 System.Windows.Forms.ToolStripDropDown.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)
在 EducationalAdmin.Program.Main() 位置 F:\高级C#\EducationalAdmin\EducationalAdmin\Program.cs:行号 19
在 System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Threading.ThreadHelper.ThreadStart()
InnerException:
/size]
...全文
115 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
wsdydmw 2009-12-06
  • 打赏
  • 举报
回复
那咋办。。。[Quote=引用 3 楼 pcqpzq 的回复:]
你调用存储过程方法不对,存储过程所需的参数没有传入
[/Quote]
pcqpzq 2009-12-06
  • 打赏
  • 举报
回复
你调用存储过程方法不对,存储过程所需的参数没有传入
wsdydmw 2009-12-05
  • 打赏
  • 举报
回复
这是什么意思System.Data.SqlClient.SqlException: 被准备语句 '(@Courseid varchar(8000),@Coursename varchar(8000),@PeacetimeT i' 需要参数 @Courseid,但未提供该参数。
wsdydmw 2009-12-05
  • 打赏
  • 举报
回复
不好意思 异常语句应该是
System.Data.SqlClient.SqlException: 被准备语句 '(@Courseid varchar(8000),@Coursename varchar(8000),@PeacetimeT i' 需要参数 @Courseid,但未提供该参数。
在 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)
在 System.Data.Common.DbDataAdapter.UpdateFromDataTable(DataTable dataTable, DataTableMapping tableMapping)
在 System.Data.Common.DbDataAdapter.Update(DataSet dataSet, String srcTable)
在 EducationalAdmin.课程管理.CourseQueryForm.button3_Click(Object sender, EventArgs e) 位置 F:\高级C#\EducationalAdmin\EducationalAdmin\课程管理\CourseQueryForm.cs:行号 83

111,120

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧