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. Database & SysAdmin
  3. Database
  4. updating a record

updating a record

Scheduled Pinned Locked Moved Database
questionhelpannouncement
6 Posts 3 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.
  • R Offline
    R Offline
    Rharzkie
    wrote on last edited by
    #1

    I can't update my a record because when i run my program, my program stops when i click the update button. A dialog box appear and it says: An unhandled exception of type 'System.IndexOutOfRangeException' occurred in system.data.dll Additional information: There is no row at position 10. My codes for the update button is: DataSet21.studentsubjects.Rows(ctr).BeginEdit() dr("grade") = txtgrade.Text DataSet21.studentsubjects.Rows(ctr).EndEdit() OleDbDataAdapter2.Update(DataSet21, "studentsubjects") MsgBox("The grade is recorded") Is there anything wrong with my codes? The error is maybe at first line? How can i correct this?

    S B 2 Replies Last reply
    0
    • R Rharzkie

      I can't update my a record because when i run my program, my program stops when i click the update button. A dialog box appear and it says: An unhandled exception of type 'System.IndexOutOfRangeException' occurred in system.data.dll Additional information: There is no row at position 10. My codes for the update button is: DataSet21.studentsubjects.Rows(ctr).BeginEdit() dr("grade") = txtgrade.Text DataSet21.studentsubjects.Rows(ctr).EndEdit() OleDbDataAdapter2.Update(DataSet21, "studentsubjects") MsgBox("The grade is recorded") Is there anything wrong with my codes? The error is maybe at first line? How can i correct this?

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

      Check whether the DataSet21.studentsubjects.Rows(ctr) is not null... before you do the edit!!!!

      I was born dumb!! :laugh:Programming made me laugh:laugh:!!! --sid--

      R 1 Reply Last reply
      0
      • R Rharzkie

        I can't update my a record because when i run my program, my program stops when i click the update button. A dialog box appear and it says: An unhandled exception of type 'System.IndexOutOfRangeException' occurred in system.data.dll Additional information: There is no row at position 10. My codes for the update button is: DataSet21.studentsubjects.Rows(ctr).BeginEdit() dr("grade") = txtgrade.Text DataSet21.studentsubjects.Rows(ctr).EndEdit() OleDbDataAdapter2.Update(DataSet21, "studentsubjects") MsgBox("The grade is recorded") Is there anything wrong with my codes? The error is maybe at first line? How can i correct this?

        B Offline
        B Offline
        Blue_Boy
        wrote on last edited by
        #3

        Simply, you dont have record at position 10


        I Love SQL

        R 1 Reply Last reply
        0
        • S sidbaruah

          Check whether the DataSet21.studentsubjects.Rows(ctr) is not null... before you do the edit!!!!

          I was born dumb!! :laugh:Programming made me laugh:laugh:!!! --sid--

          R Offline
          R Offline
          Rharzkie
          wrote on last edited by
          #4

          Ah ok., it means that all my records have already data and not null, thanks...

          1 Reply Last reply
          0
          • B Blue_Boy

            Simply, you dont have record at position 10


            I Love SQL

            R Offline
            R Offline
            Rharzkie
            wrote on last edited by
            #5

            ok, thanks. i already put a data in each record so i can already update it but the problem is, the data that i enter goes in other row instead of the correct row. Example: my table goes like this: i have 3 fields- 1. ID(primary key) 2. Studname 3. grade i have 4 records: The 4 studname are- 'rissa', 'kristine', 'cherry', 'glenda' i have to enter a grade for each. The data written in their grade is "no yet grade" so that it can't be null. i search ID '1' which is for 'rissa', then i enter a grade for 'rissa which is '95', but the grade goes in the record of 'kristine' what is the problem in that? how can i correct?

            B 1 Reply Last reply
            0
            • R Rharzkie

              ok, thanks. i already put a data in each record so i can already update it but the problem is, the data that i enter goes in other row instead of the correct row. Example: my table goes like this: i have 3 fields- 1. ID(primary key) 2. Studname 3. grade i have 4 records: The 4 studname are- 'rissa', 'kristine', 'cherry', 'glenda' i have to enter a grade for each. The data written in their grade is "no yet grade" so that it can't be null. i search ID '1' which is for 'rissa', then i enter a grade for 'rissa which is '95', but the grade goes in the record of 'kristine' what is the problem in that? how can i correct?

              B Offline
              B Offline
              Blue_Boy
              wrote on last edited by
              #6

              1. Drag one label in your form and name it lblID 2.In your GridView1 selectedIndexChange event (I am giving this example for asp.net) set text of selectedrow and specify cell's text then set text to lblID. (In this case select row which contain name Risa) lblID.Text = GridView1.SelectedRow.Cells[1].Text;//Instead index 1 in Cells property can differ from my example 3. In Update button set update command : " Update YourTableName set Grade='95' where [ID]='"+lblID.Text+"'"; 4.Then bind GridView1. GridView1.DataBind();


              I Love SQL

              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