VISUAL STUDIO 2008 DATABASE ERROR! NEED YOUR HELP ASAP!
Posted: Sun Feb 19, 2012 2:26 pm
Hello Guys! I NEED YOUR HELP!!!?
I have a problem guys with regards to my project..
my problem is that I cannot Update or Delete the FIRST RECORD if I will not click or move the next button first or the navigation buttons..
BUT if I am going to UPDATE or DELETE the FIRST RECORD without moving or clicking the navigation buttons, I come up with this error:
>>>>>>>>>>>>>> "There is no row at position -1" <<<<<<<<<<
I have already a primary key in my table.. .I'm using MS Access.
It's almost 3 weeks of trying to find the solution for this problem...
what should I do guys??
here is the code if ever you want to see:
for UPDATE:
Dim cb As New OleDb.OleDbCommandBuilder(da)
ds.Tables("pok").Rows(inc).Item("Borrowe… = txtname.Text <<< The ERROR points in this part!
ds.Tables("pok").Rows(inc).Item("LastNam… = txtlast.Text
ds.Tables("pok").Rows(inc).Item("Address… = txtadd.Text
ds.Tables("pok").Rows(inc).Item("Contact… = txtcontact.Text
da.Update(ds, "pok")
MsgBox("Data updated")
for DELETE:
Dim cb As New OleDb.OleDbCommandBuilder(da)
If MessageBox.Show("Do you really want to Delete this Record?", _
"Delete", MessageBoxButtons.YesNo, _
MessageBoxIcon.Warning) = DialogResult.No Then
inc = 0
NavigateRecords()
MsgBox("Operation Cancelled!")
Exit Sub
End If
ds.Tables("pok").Rows(inc).Delete() <<< The ERROR points in this part!
MaxRows = MaxRows - 1
inc = 0
NavigateRecords()
da.Update(ds, "pok")
and SOMETIMES in this code:
Private Sub NavigateRecords()
txtname.Text = ds.Tables("pok").Rows(inc).Item(0) <<< The ERROR points in this part!
txtlast.Text = ds.Tables("pok").Rows(inc).Item(1)
txtadd.Text = ds.Tables("pok").Rows(inc).Item(2)
End Sub
One thing guys! If I am going to add records some of the fields of my database in empty and this made my project errors too..
my source or my guide of this code is: http://www.homeandlearn.co.uk/net/vbnet.html in the 13th part or chapter..
PLEASE GUYS I REALLY NEED YOUR HELP! THANKS VERY MUCH AND GOD BLESS!
I have a problem guys with regards to my project..
my problem is that I cannot Update or Delete the FIRST RECORD if I will not click or move the next button first or the navigation buttons..
BUT if I am going to UPDATE or DELETE the FIRST RECORD without moving or clicking the navigation buttons, I come up with this error:
>>>>>>>>>>>>>> "There is no row at position -1" <<<<<<<<<<
I have already a primary key in my table.. .I'm using MS Access.
It's almost 3 weeks of trying to find the solution for this problem...
what should I do guys??
here is the code if ever you want to see:
for UPDATE:
Dim cb As New OleDb.OleDbCommandBuilder(da)
ds.Tables("pok").Rows(inc).Item("Borrowe… = txtname.Text <<< The ERROR points in this part!
ds.Tables("pok").Rows(inc).Item("LastNam… = txtlast.Text
ds.Tables("pok").Rows(inc).Item("Address… = txtadd.Text
ds.Tables("pok").Rows(inc).Item("Contact… = txtcontact.Text
da.Update(ds, "pok")
MsgBox("Data updated")
for DELETE:
Dim cb As New OleDb.OleDbCommandBuilder(da)
If MessageBox.Show("Do you really want to Delete this Record?", _
"Delete", MessageBoxButtons.YesNo, _
MessageBoxIcon.Warning) = DialogResult.No Then
inc = 0
NavigateRecords()
MsgBox("Operation Cancelled!")
Exit Sub
End If
ds.Tables("pok").Rows(inc).Delete() <<< The ERROR points in this part!
MaxRows = MaxRows - 1
inc = 0
NavigateRecords()
da.Update(ds, "pok")
and SOMETIMES in this code:
Private Sub NavigateRecords()
txtname.Text = ds.Tables("pok").Rows(inc).Item(0) <<< The ERROR points in this part!
txtlast.Text = ds.Tables("pok").Rows(inc).Item(1)
txtadd.Text = ds.Tables("pok").Rows(inc).Item(2)
End Sub
One thing guys! If I am going to add records some of the fields of my database in empty and this made my project errors too..
my source or my guide of this code is: http://www.homeandlearn.co.uk/net/vbnet.html in the 13th part or chapter..
PLEASE GUYS I REALLY NEED YOUR HELP! THANKS VERY MUCH AND GOD BLESS!