Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / General / September 2005

Tip: Looking for answers? Try searching our database.

VS2005 TableAdapter update

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ybc - 22 Sep 2005 05:02 GMT
Hi,
I 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
ybc - 22 Sep 2005 07:59 GMT
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?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.