updating a record
-
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? -
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? -
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? -
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--
-
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?
-
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?
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