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. Saving Modified Column Value in Datagridview to Database

Saving Modified Column Value in Datagridview to Database

Scheduled Pinned Locked Moved Visual Basic
databasehelpquestion
8 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.
  • D Offline
    D Offline
    Dambod
    wrote on last edited by
    #1

    hi there, i have a datagridview controls that gets its data from database, i want to edit (modify) some rows and send back the modified content of all rows that are found under the same column to databases. Any help? Thank u in advance

    M 1 Reply Last reply
    0
    • D Dambod

      hi there, i have a datagridview controls that gets its data from database, i want to edit (modify) some rows and send back the modified content of all rows that are found under the same column to databases. Any help? Thank u in advance

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      It is actually quicker and easier to try a search[^] before posting a question. This probably ranks as one of the most asked questions in the forums.

      Never underestimate the power of human stupidity RAH

      D 1 Reply Last reply
      0
      • M Mycroft Holmes

        It is actually quicker and easier to try a search[^] before posting a question. This probably ranks as one of the most asked questions in the forums.

        Never underestimate the power of human stupidity RAH

        D Offline
        D Offline
        Dambod
        wrote on last edited by
        #3

        would help me with it plz, my code under save button is this? thank u in adnvance For i As Integer = 0 To DataGridView1.Rows.Count - 1 'DataGridView1(3, i) Try c.cmd = New SqlCommand("update courseregistered set lettergrade='" & DataGridView1(3, i).Value.ToString & "' where courseno='" & (ComboBox1.SelectedItem.ToString).Substring(0, 7) & "' and studid='" & DataGridView1.SelectedCells(i).Value.ToString & "'", c.cn) c.cmd.CommandType = CommandType.Text c.cmd.ExecuteNonQuery() Catch ex As NullReferenceException MsgBox(ex.Message) End Try Next c.da.Update(c.ds, "courseregistered") MsgBox("update has been succesful") it will save the last row under the column and display "update successful" message but ignores other rows in the column

        M 1 Reply Last reply
        0
        • D Dambod

          would help me with it plz, my code under save button is this? thank u in adnvance For i As Integer = 0 To DataGridView1.Rows.Count - 1 'DataGridView1(3, i) Try c.cmd = New SqlCommand("update courseregistered set lettergrade='" & DataGridView1(3, i).Value.ToString & "' where courseno='" & (ComboBox1.SelectedItem.ToString).Substring(0, 7) & "' and studid='" & DataGridView1.SelectedCells(i).Value.ToString & "'", c.cn) c.cmd.CommandType = CommandType.Text c.cmd.ExecuteNonQuery() Catch ex As NullReferenceException MsgBox(ex.Message) End Try Next c.da.Update(c.ds, "courseregistered") MsgBox("update has been succesful") it will save the last row under the column and display "update successful" message but ignores other rows in the column

          M Offline
          M Offline
          Mycroft Holmes
          wrote on last edited by
          #4

          :sigh: What error message are you getting? What is c as in c.cmd = new etc

          Dambod wrote:

          c.da.Update(c.ds, "courseregistered")

          What do you expect this to do, dammed stoopid MS wizarded crap, why people can't use a proper DAL I don't know.

          Never underestimate the power of human stupidity RAH

          D 1 Reply Last reply
          0
          • M Mycroft Holmes

            :sigh: What error message are you getting? What is c as in c.cmd = new etc

            Dambod wrote:

            c.da.Update(c.ds, "courseregistered")

            What do you expect this to do, dammed stoopid MS wizarded crap, why people can't use a proper DAL I don't know.

            Never underestimate the power of human stupidity RAH

            D Offline
            D Offline
            Dambod
            wrote on last edited by
            #5

            c is the class where the dataAdpater and dataset are declared and set. it says "Obect reference not set to an instance of an object

            M D 2 Replies Last reply
            0
            • D Dambod

              c is the class where the dataAdpater and dataset are declared and set. it says "Obect reference not set to an instance of an object

              M Offline
              M Offline
              Mycroft Holmes
              wrote on last edited by
              #6

              try adding this to the start of the method

              c = new classname()

              Never underestimate the power of human stupidity RAH

              D 1 Reply Last reply
              0
              • M Mycroft Holmes

                try adding this to the start of the method

                c = new classname()

                Never underestimate the power of human stupidity RAH

                D Offline
                D Offline
                Dambod
                wrote on last edited by
                #7

                i have set that line already while declaration

                1 Reply Last reply
                0
                • D Dambod

                  c is the class where the dataAdpater and dataset are declared and set. it says "Obect reference not set to an instance of an object

                  D Offline
                  D Offline
                  Dambod
                  wrote on last edited by
                  #8

                  i have got the solutions to my problems, thanks the support i received from u

                  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