Cannot update or delete access database
-
I am trying to update and delete ,but get this error code now, it did work before. error code == "There is no row at position -1" My update code
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
Dim cb As New OleDb.OleDbCommandBuilder(da) ds.Tables("Blokkies").Rows(inc).Item(1) = TxtLuidraad.Text ds.Tables("Blokkies").Rows(inc).Item(2) = txtA1.Text ds.Tables("Blokkies").Rows(inc).Item(3) = txtA2.Text ds.Tables("Blokkies").Rows(inc).Item(4) = txtA3.Text ds.Tables("Blokkies").Rows(inc).Item(5) = txtA4.Text ds.Tables("Blokkies").Rows(inc).Item(6) = txtA5.Text ds.Tables("Blokkies").Rows(inc).Item(7) = txtA6.Text ds.Tables("Blokkies").Rows(inc).Item(8) = txtA7.Text ds.Tables("Blokkies").Rows(inc).Item(9) = txtA8.Text ds.Tables("Blokkies").Rows(inc).Item(10) = txtA9.Text ds.Tables("Blokkies").Rows(inc).Item(11) = txtA10.Text ds.Tables("Blokkies").Rows(inc).Item(12) = txtA10.Text ds.Tables("Blokkies").Rows(inc).Item(13) = txtA10.Text da.Update(ds, "Blokkies") MsgBox("Register verander") End Sub
I did try to use this, but still get same error
If Not IsDBNull(ds.Tables("Blokkies").Rows(inc).Item("luidraad")) Then
ds.Tables("Blokkies").Rows(inc).Item(1) = TxtLuidraad.Text
End IfMy delete code
Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click
If MessageBox.Show("Is jy seker jy wil die register verwyder?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) = DialogResult.No Then MsgBox("Register is nie verwyder nie") Exit Sub End If Dim cb As New OleDb.OleDbCommandBuilder(da) ds.Tables("Blokkies").Rows(inc).Delete() maxrows = maxrows - 1 inc = 0 NavigateRecords() da.Update(ds, "Blokkies") End Sub
-
I am trying to update and delete ,but get this error code now, it did work before. error code == "There is no row at position -1" My update code
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
Dim cb As New OleDb.OleDbCommandBuilder(da) ds.Tables("Blokkies").Rows(inc).Item(1) = TxtLuidraad.Text ds.Tables("Blokkies").Rows(inc).Item(2) = txtA1.Text ds.Tables("Blokkies").Rows(inc).Item(3) = txtA2.Text ds.Tables("Blokkies").Rows(inc).Item(4) = txtA3.Text ds.Tables("Blokkies").Rows(inc).Item(5) = txtA4.Text ds.Tables("Blokkies").Rows(inc).Item(6) = txtA5.Text ds.Tables("Blokkies").Rows(inc).Item(7) = txtA6.Text ds.Tables("Blokkies").Rows(inc).Item(8) = txtA7.Text ds.Tables("Blokkies").Rows(inc).Item(9) = txtA8.Text ds.Tables("Blokkies").Rows(inc).Item(10) = txtA9.Text ds.Tables("Blokkies").Rows(inc).Item(11) = txtA10.Text ds.Tables("Blokkies").Rows(inc).Item(12) = txtA10.Text ds.Tables("Blokkies").Rows(inc).Item(13) = txtA10.Text da.Update(ds, "Blokkies") MsgBox("Register verander") End Sub
I did try to use this, but still get same error
If Not IsDBNull(ds.Tables("Blokkies").Rows(inc).Item("luidraad")) Then
ds.Tables("Blokkies").Rows(inc).Item(1) = TxtLuidraad.Text
End IfMy delete code
Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click
If MessageBox.Show("Is jy seker jy wil die register verwyder?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) = DialogResult.No Then MsgBox("Register is nie verwyder nie") Exit Sub End If Dim cb As New OleDb.OleDbCommandBuilder(da) ds.Tables("Blokkies").Rows(inc).Delete() maxrows = maxrows - 1 inc = 0 NavigateRecords() da.Update(ds, "Blokkies") End Sub
-
sorry, how do you check the value and that the daataset is not empty
-
sorry, how do you check the value and that the daataset is not empty
-
I am trying to update and delete ,but get this error code now, it did work before. error code == "There is no row at position -1" My update code
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
Dim cb As New OleDb.OleDbCommandBuilder(da) ds.Tables("Blokkies").Rows(inc).Item(1) = TxtLuidraad.Text ds.Tables("Blokkies").Rows(inc).Item(2) = txtA1.Text ds.Tables("Blokkies").Rows(inc).Item(3) = txtA2.Text ds.Tables("Blokkies").Rows(inc).Item(4) = txtA3.Text ds.Tables("Blokkies").Rows(inc).Item(5) = txtA4.Text ds.Tables("Blokkies").Rows(inc).Item(6) = txtA5.Text ds.Tables("Blokkies").Rows(inc).Item(7) = txtA6.Text ds.Tables("Blokkies").Rows(inc).Item(8) = txtA7.Text ds.Tables("Blokkies").Rows(inc).Item(9) = txtA8.Text ds.Tables("Blokkies").Rows(inc).Item(10) = txtA9.Text ds.Tables("Blokkies").Rows(inc).Item(11) = txtA10.Text ds.Tables("Blokkies").Rows(inc).Item(12) = txtA10.Text ds.Tables("Blokkies").Rows(inc).Item(13) = txtA10.Text da.Update(ds, "Blokkies") MsgBox("Register verander") End Sub
I did try to use this, but still get same error
If Not IsDBNull(ds.Tables("Blokkies").Rows(inc).Item("luidraad")) Then
ds.Tables("Blokkies").Rows(inc).Item(1) = TxtLuidraad.Text
End IfMy delete code
Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click
If MessageBox.Show("Is jy seker jy wil die register verwyder?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) = DialogResult.No Then MsgBox("Register is nie verwyder nie") Exit Sub End If Dim cb As New OleDb.OleDbCommandBuilder(da) ds.Tables("Blokkies").Rows(inc).Delete() maxrows = maxrows - 1 inc = 0 NavigateRecords() da.Update(ds, "Blokkies") End Sub
You don't appear to be setting the value of inc anywhere before you try to use it.
Knowledge is knowing that the tomato is a fruit. Wisdom is not putting it in fruit salad!! Booger Mobile - Camp Quality esCarpade 2010
-
You don't appear to be setting the value of inc anywhere before you try to use it.
Knowledge is knowing that the tomato is a fruit. Wisdom is not putting it in fruit salad!! Booger Mobile - Camp Quality esCarpade 2010
I am new to databse, I don't know how to set the value in the code yet. I did try this, but it is not working If inc <> -1 Then ds.Tables("Blokkies").Rows(inc).Item(1) = TxtLuidraad.Text ds.Tables("Blokkies").Rows(inc).Item(2) = txtA1.Text ds.Tables("Blokkies").Rows(inc).Item(3) = txtA2.Text ds.Tables("Blokkies").Rows(inc).Item(4) = txtA3.Text ds.Tables("Blokkies").Rows(inc).Item(5) = txtA4.Text ds.Tables("Blokkies").Rows(inc).Item(6) = txtA5.Text ds.Tables("Blokkies").Rows(inc).Item(7) = txtA6.Text ds.Tables("Blokkies").Rows(inc).Item(8) = txtA7.Text ds.Tables("Blokkies").Rows(inc).Item(9) = txtA8.Text ds.Tables("Blokkies").Rows(inc).Item(10) = txtA9.Text ds.Tables("Blokkies").Rows(inc).Item(11) = txtA10.Text ds.Tables("Blokkies").Rows(inc).Item(12) = txtA11.Text ds.Tables("Blokkies").Rows(inc).Item(13) = txtA12.Text da.Update(ds, "Blokkies") MsgBox("Register verander") End If
modified on Thursday, March 19, 2009 2:27 AM
-
I am new to databse, I don't know how to set the value in the code yet. I did try this, but it is not working If inc <> -1 Then ds.Tables("Blokkies").Rows(inc).Item(1) = TxtLuidraad.Text ds.Tables("Blokkies").Rows(inc).Item(2) = txtA1.Text ds.Tables("Blokkies").Rows(inc).Item(3) = txtA2.Text ds.Tables("Blokkies").Rows(inc).Item(4) = txtA3.Text ds.Tables("Blokkies").Rows(inc).Item(5) = txtA4.Text ds.Tables("Blokkies").Rows(inc).Item(6) = txtA5.Text ds.Tables("Blokkies").Rows(inc).Item(7) = txtA6.Text ds.Tables("Blokkies").Rows(inc).Item(8) = txtA7.Text ds.Tables("Blokkies").Rows(inc).Item(9) = txtA8.Text ds.Tables("Blokkies").Rows(inc).Item(10) = txtA9.Text ds.Tables("Blokkies").Rows(inc).Item(11) = txtA10.Text ds.Tables("Blokkies").Rows(inc).Item(12) = txtA11.Text ds.Tables("Blokkies").Rows(inc).Item(13) = txtA12.Text da.Update(ds, "Blokkies") MsgBox("Register verander") End If
modified on Thursday, March 19, 2009 2:27 AM
You're entering a contest to see who can write the most illegible code ?
Christian Graus Driven to the arms of OSX by Vista.
-
You're entering a contest to see who can write the most illegible code ?
Christian Graus Driven to the arms of OSX by Vista.
now what is the best why do wright this code, I am new and want to get this right.
-
now what is the best why do wright this code, I am new and want to get this right.
Like I said, your best option is to let your client know you're not the right man for the job. Buy some books and read them. Learn how to program before having clients.
Christian Graus Driven to the arms of OSX by Vista.
-
I am new to databse, I don't know how to set the value in the code yet. I did try this, but it is not working If inc <> -1 Then ds.Tables("Blokkies").Rows(inc).Item(1) = TxtLuidraad.Text ds.Tables("Blokkies").Rows(inc).Item(2) = txtA1.Text ds.Tables("Blokkies").Rows(inc).Item(3) = txtA2.Text ds.Tables("Blokkies").Rows(inc).Item(4) = txtA3.Text ds.Tables("Blokkies").Rows(inc).Item(5) = txtA4.Text ds.Tables("Blokkies").Rows(inc).Item(6) = txtA5.Text ds.Tables("Blokkies").Rows(inc).Item(7) = txtA6.Text ds.Tables("Blokkies").Rows(inc).Item(8) = txtA7.Text ds.Tables("Blokkies").Rows(inc).Item(9) = txtA8.Text ds.Tables("Blokkies").Rows(inc).Item(10) = txtA9.Text ds.Tables("Blokkies").Rows(inc).Item(11) = txtA10.Text ds.Tables("Blokkies").Rows(inc).Item(12) = txtA11.Text ds.Tables("Blokkies").Rows(inc).Item(13) = txtA12.Text da.Update(ds, "Blokkies") MsgBox("Register verander") End If
modified on Thursday, March 19, 2009 2:27 AM
I'm sorry, I thought you were someone else. Break it down into steps. Write code that checks that a table of that name exists, that it has rows, etc. Then step through the code in the debugger.
Christian Graus Driven to the arms of OSX by Vista.