problem with delete button

wongth7

Member
Joined
Jun 16, 2009
Messages
7
Programming Experience
Beginner
hi guys..im having a problem with my delete button

(let's say my database has 3 records)

and while my form is showing record no.3, and i clicked on the delete button, it will delete record no.1..(it supposed to be deleting record no.3)....how to correct my code and make it delete the record shown on the form????


here's my code...

VB.NET:
Private Sub frmManager_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
       'TODO: This line of code loads data into the 'UserDataSet2.Staffapplication' table. You can move, or remove it, as needed.
       Me.StaffapplicationTableAdapter.Fill(Me.UserDataSet2.Staffapplication)

       txtRecordno.DataBindings.Add("Text", UserDataSet2, "Staffapplication.Srecordno")
       txtUsername.DataBindings.Add("Text", UserDataSet2, "Staffapplication.Sname")
       txtPassword.DataBindings.Add("Text", UserDataSet2, "Staffapplication.Spassword")
       txtHobby.DataBindings.Add("Text", UserDataSet2, "Staffapplication.Shobby")

   End Sub

______________________________________________________________

Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click


       Dim intresult As Integer

       Try
           intresult = MessageBox.Show("Confirm Delete?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
           If intresult = Windows.Forms.DialogResult.Yes Then
               Me.StaffapplicationBindingSource.RemoveCurrent()
               Me.StaffapplicationTableAdapter.Update(Me.UserDataSet2.Staffapplication)

           End If
       Catch ex As Exception

       End Try

here's my form
 

Attachments

  • Screen1.jpg
    Screen1.jpg
    14.5 KB · Views: 21
Last edited:
Back
Top