|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
VS2005 TableAdapter updateI use VS2005 create a project – “Slemailâ€. In DataSet1 there’s a table of customer email address data - “slemailâ€. I drag “slemail†table to the form. It displays the data by DataGridView control and creates “SlemailBindingSourceâ€, “SlemailTableAdapter†and “SlemailBindingNavigatorâ€. It generates the following code of a function: Private Sub bindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bindingNavigatorSaveItem.Click If Me.Validate Then Me.SlemailBindingSource.EndEdit() Me.SlemailTableAdapter.Update(Me.DataSet1.slemail) Else System.Windows.Forms.MessageBox.Show(Me, "Validation errors occurred.", "Save", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning) End If End Sub When I start debugging and click the “save†button on the bindingNavigator there’s an error message. The error detail is as the following: ------------------------------------------------ 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 SLEmail.DataSet1TableAdapters.slemailTableAdapter.Update(slemailDataTable dataTable) in D:\Projects\VB\SLEmail\DataSet1.Designer.vb:line 1051 at SLEmail.email.bindingNavigatorSaveItem_Click(Object sender, EventArgs e) in D:\Projects\VB\SLEmail\email.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 SLEmail.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 76 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() --------------------------------------------------------------- What that means? What can I do about it? I think it’d be something to do with the selection in TableAdapter Configuration Wizard. Should choose the option “Generate Insert, Update and Delete statements†in Advanced Options? Should choose the option “Return a DataTable†and “Create methods to send updates directly to the databaseâ€? I cannot find clue in online help and samples. Thanks. ybc I use a MS Datalink file and .NET Framework Data Provider for OLE DB(MS OLE
DB Provider for SQL Server) for database connection. The Wizard Results of Table Adapter Configuration Wizard shows a list of tasks wizard has performed as the following: Generated SELECT statement. Generated INSERT statement. Generated table mappings. Generated Fill method. Generated Get method. Generated update methods. It doesn’t generate “UPDATE†and “DELETE†statements. Why? If the MS OLE DB Provider for SQL Server doesn’t support them? "ybc" <y**@discussions.microsoft.com> wrote in message news:D5EE3403- 7949-4361-A04B-8291CC560***@microsoft.comShow quoteHide quote > Hi, > I use VS2005 create a project – “Slemailâ€. In DataSet1 there’s a -- <response type="generic" language="VB.Net"> This newsgroup is for users of Visual Basic version 6.0 and earlier and not the misleadingly named VB.Net or VB 200x. Solutions, and often even the questions, for one platform will be meaningless in the other. When VB.Net was released Microsoft created new newsgroups devoted to the new platform so that neither group of developers need wade through the clutter of unrelated topics. Look for newsgroups with the words "dotnet" or "vsnet" in their name. For the msnews.microsoft.com news server try these: microsoft.public.dotnet.general microsoft.public.dotnet.languages.vb </response>
Other interesting topics
|
|||||||||||||||||||||||