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
  1. Home
  2. General Programming
  3. Visual Basic
  4. update problem

update problem

Scheduled Pinned Locked Moved Visual Basic
helpcssdatabaseannouncement
3 Posts 2 Posters 0 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.
  • A Offline
    A Offline
    asha_s
    wrote on last edited by
    #1

    hi smile.gif i have the fellowing code for updating the database when its change in data grid While (r < DataGridView1.Rows.Count - 1) InsertCommand1.Parameters.Clear() InsertCommand1.CommandText = "UPDATE [Section] SET Capacity =" & DataGridView1.Rows(r).Cells(2).Value & " WHERE SectionID = " & DataGridView1.Rows(r).Cells(1).Value InsertCommand1.CommandType = CommandType.Text InsertCommand1 = InsertCommand1 DataAdapter1.InsertCommand = InsertCommand1 InsertCommand1.ExecuteNonQuery() DataAdapter1.Update(DataSet1, "Section") r += 1 End While it make the update but it give the fellowing error Update requires a valid UpdateCommand when passed DataRow collection with modified rows. when i but the fellowing command Dim CmdB As New OleDb.OleDbCommandBuilder(DataAdapter1) it give error in update statment

    C 1 Reply Last reply
    0
    • A asha_s

      hi smile.gif i have the fellowing code for updating the database when its change in data grid While (r < DataGridView1.Rows.Count - 1) InsertCommand1.Parameters.Clear() InsertCommand1.CommandText = "UPDATE [Section] SET Capacity =" & DataGridView1.Rows(r).Cells(2).Value & " WHERE SectionID = " & DataGridView1.Rows(r).Cells(1).Value InsertCommand1.CommandType = CommandType.Text InsertCommand1 = InsertCommand1 DataAdapter1.InsertCommand = InsertCommand1 InsertCommand1.ExecuteNonQuery() DataAdapter1.Update(DataSet1, "Section") r += 1 End While it make the update but it give the fellowing error Update requires a valid UpdateCommand when passed DataRow collection with modified rows. when i but the fellowing command Dim CmdB As New OleDb.OleDbCommandBuilder(DataAdapter1) it give error in update statment

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      asha_s wrote:

      Update requires a valid UpdateCommand when passed DataRow collection with modified rows.

      These built in update things suck. However, if you must use them, this error is telling you that you need to specify the update command ( the SQL that does the update )

      Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

      A 1 Reply Last reply
      0
      • C Christian Graus

        asha_s wrote:

        Update requires a valid UpdateCommand when passed DataRow collection with modified rows.

        These built in update things suck. However, if you must use them, this error is telling you that you need to specify the update command ( the SQL that does the update )

        Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

        A Offline
        A Offline
        asha_s
        wrote on last edited by
        #3

        Christian Graus wrote:

        this error is telling you that you need to specify the update command ( the SQL that does the update )

        how can i specify it i am sure from the type of the sended perimeter if you have another way rather than command please tell me :(( :((

        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