VISUAL STUDIO 2008 DATABASE ERROR! NEED YOUR HELP ASAP!
If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
8 posts
Page 1 of 1
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!
Im not familiar with database coding but from looking at your post and the error which says ">>>>>>>>>>>>>> "There is no row at position -1" <<<<<<<<<<" I think some variable in your code should not be allowed to go below 0 or 1
Try change the variable Inc to 1 at the start of your code or wherever its declared.
What is the code you have for the navigation buttons?
Try change the variable Inc to 1 at the start of your code or wherever its declared.
What is the code you have for the navigation buttons?
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
Before the codes for my navigation. Sir, I am very thankful that you give attention to my question.. because our instructor did not discussed this topic to us he just gave us the site (which I posted with my question) that's why we almost going crazy to find the solution of the errors, for the site explanation itself is incomplete... God Bless You Sir! More Power to this site. Thanks very much!
________________________________________________________________
CODES FOR FIRST RECORD
Private Sub btnfirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnfirst.Click
If inc <> 0 Then
inc = 0
NavigateRecords()
End If
End Sub
_____________________________________________________________________________
CODES FOR LAST RECORD
Private Sub btnlast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnlast.Click
If inc <> MaxRows - 1 Then
inc = MaxRows - 1
NavigateRecords()
End If
End Sub
__________________________________________________________________________
CODES TO MOVE NEXT RECORD
Private Sub btnnext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnnext.Click
If inc <> MaxRows - 1 Then
inc = inc + 1
NavigateRecords()
Else
MsgBox("No More Records!")
End If
End Sub
_______________________________________________________________________________
CODES TO MOVE PREVIOUS RECORD
Private Sub btnprevious_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnprevious.Click
If inc > 0 Then
inc = inc - 1
NavigateRecords()
ElseIf inc = -1 Then
MsgBox("No Records Yet")
ElseIf inc = 0 Then
MsgBox("First Record")
End If
End Sub
Please use the code tags to show codes.
Code: Select all
These tags
Practice makes perfect!
VIP since: 6-10-2011
VIP since: 6-10-2011
clanc789 wrote:Please use the code tags to show codes.Code: Select allThese tags
what do you mean Sir? Thanks!
If you show your codes (e.g.):
Code: Select all
Private Sub btnprevious_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnprevious.Click
If inc > 0 Then
inc = inc - 1
NavigateRecords()
ElseIf inc = -1 Then
MsgBox("No Records Yet")
ElseIf inc = 0 Then
MsgBox("First Record")
End If
End Sub
Practice makes perfect!
VIP since: 6-10-2011
VIP since: 6-10-2011
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
thanks for the response guys, I really appreciate the effort but sadly I still have the same errors.. I am still working and looking for the solution.. cryer;
Godbless!
Godbless!
8 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023