Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. I'm stuck on - Update requires a valid UpdateCommand when passed DataRow collection with modified rows.

I'm stuck on - Update requires a valid UpdateCommand when passed DataRow collection with modified rows.

Scheduled Pinned Locked Moved Database
helpcsharpdatabasevisual-studiosysadmin
4 Posts 3 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    gmhanna
    wrote on last edited by
    #1

    Hi, I'm writing an application and I keep receiving an "Invalid Operation Exception" with this message: "Update requires a valid UpdateCommand when passed DataRow collection with modified rows." I created a DataSource using the "Add New Data Source" option from Visual Studio 2010 and dragged the controls onto the form. The dataset is set to detail instead of datagrid. Showing at the bottom of the form I have a ktReunionDataset, reunionBindingSource, reunionTableAdapter, tableAdapterManager. This table was originally created from a MS-Access database and then was cloned using Visual Studio. I assigned a primary key to the "ID" field through the Server Explorer via the Open Table Definition, then right clicking on the ID field and assigning it the Primary Key. The ID field shows a key icon indicating it's the Primary Key. The code for the Save button off the navigator looks like this:

        private void reunionBindingNavigatorSaveItem\_Click(object sender, EventArgs e)
        {
            this.Validate();
            this.reunionBindingSource.EndEdit();
            this.tableAdapterManager.UpdateAll(this.kTReunionDataSet);
    
       } 
    

    Do I need to manually code an update for when the user presses the save button, and iterating through each entry? I have looked at other examples and it doesn't have an update attached to the Data Adapter only Fill and FillByxxx so I'm not sure I need to add something here? Any help is appreciated. Thank you,

    Glenn

    S J G 3 Replies Last reply
    0
    • G gmhanna

      Hi, I'm writing an application and I keep receiving an "Invalid Operation Exception" with this message: "Update requires a valid UpdateCommand when passed DataRow collection with modified rows." I created a DataSource using the "Add New Data Source" option from Visual Studio 2010 and dragged the controls onto the form. The dataset is set to detail instead of datagrid. Showing at the bottom of the form I have a ktReunionDataset, reunionBindingSource, reunionTableAdapter, tableAdapterManager. This table was originally created from a MS-Access database and then was cloned using Visual Studio. I assigned a primary key to the "ID" field through the Server Explorer via the Open Table Definition, then right clicking on the ID field and assigning it the Primary Key. The ID field shows a key icon indicating it's the Primary Key. The code for the Save button off the navigator looks like this:

          private void reunionBindingNavigatorSaveItem\_Click(object sender, EventArgs e)
          {
              this.Validate();
              this.reunionBindingSource.EndEdit();
              this.tableAdapterManager.UpdateAll(this.kTReunionDataSet);
      
         } 
      

      Do I need to manually code an update for when the user presses the save button, and iterating through each entry? I have looked at other examples and it doesn't have an update attached to the Data Adapter only Fill and FillByxxx so I'm not sure I need to add something here? Any help is appreciated. Thank you,

      Glenn

      S Offline
      S Offline
      Simon_Whale
      wrote on last edited by
      #2

      have you tested your update SQL statement on the database? if so does that give an error?

      Marc Clifton wrote:

      That has nothing to do with VB. - Oh crap. I just defended VB!

      1 Reply Last reply
      0
      • G gmhanna

        Hi, I'm writing an application and I keep receiving an "Invalid Operation Exception" with this message: "Update requires a valid UpdateCommand when passed DataRow collection with modified rows." I created a DataSource using the "Add New Data Source" option from Visual Studio 2010 and dragged the controls onto the form. The dataset is set to detail instead of datagrid. Showing at the bottom of the form I have a ktReunionDataset, reunionBindingSource, reunionTableAdapter, tableAdapterManager. This table was originally created from a MS-Access database and then was cloned using Visual Studio. I assigned a primary key to the "ID" field through the Server Explorer via the Open Table Definition, then right clicking on the ID field and assigning it the Primary Key. The ID field shows a key icon indicating it's the Primary Key. The code for the Save button off the navigator looks like this:

            private void reunionBindingNavigatorSaveItem\_Click(object sender, EventArgs e)
            {
                this.Validate();
                this.reunionBindingSource.EndEdit();
                this.tableAdapterManager.UpdateAll(this.kTReunionDataSet);
        
           } 
        

        Do I need to manually code an update for when the user presses the save button, and iterating through each entry? I have looked at other examples and it doesn't have an update attached to the Data Adapter only Fill and FillByxxx so I'm not sure I need to add something here? Any help is appreciated. Thank you,

        Glenn

        J Offline
        J Offline
        Johan Hakkesteegt
        wrote on last edited by
        #3

        Please don't remove your question after you have received an answer (you posted a message regarding this problem on the VB.NET forum). Others may have the same question, and can benefit from the answers. If your adapter only has a fill command, then you may have configured it incorrectly. Try to configure it again, somewhere the wizard will ask you if you also want update, delete, and insert commands. I suspect that you left some checkbox unchecked the first time when you created the adapter.

        My advice is free, and you may get what you paid for.

        1 Reply Last reply
        0
        • G gmhanna

          Hi, I'm writing an application and I keep receiving an "Invalid Operation Exception" with this message: "Update requires a valid UpdateCommand when passed DataRow collection with modified rows." I created a DataSource using the "Add New Data Source" option from Visual Studio 2010 and dragged the controls onto the form. The dataset is set to detail instead of datagrid. Showing at the bottom of the form I have a ktReunionDataset, reunionBindingSource, reunionTableAdapter, tableAdapterManager. This table was originally created from a MS-Access database and then was cloned using Visual Studio. I assigned a primary key to the "ID" field through the Server Explorer via the Open Table Definition, then right clicking on the ID field and assigning it the Primary Key. The ID field shows a key icon indicating it's the Primary Key. The code for the Save button off the navigator looks like this:

              private void reunionBindingNavigatorSaveItem\_Click(object sender, EventArgs e)
              {
                  this.Validate();
                  this.reunionBindingSource.EndEdit();
                  this.tableAdapterManager.UpdateAll(this.kTReunionDataSet);
          
             } 
          

          Do I need to manually code an update for when the user presses the save button, and iterating through each entry? I have looked at other examples and it doesn't have an update attached to the Data Adapter only Fill and FillByxxx so I'm not sure I need to add something here? Any help is appreciated. Thank you,

          Glenn

          G Offline
          G Offline
          gmhanna
          wrote on last edited by
          #4

          I got this to work, it appears that Visual Studio did not generate the Update methods. After going into the design view of the dataset and right clicking on the Fill,GetData of the TableAdapter and selecting "Configure" then clicking NEXT all the way through re-generates everything. After doing this everything works perfect.

          Glenn

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups