Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RowRemove deleted

Status
Not open for further replies.

beautieee

Programmer
Oct 4, 2008
46
MY
Good Day,

Im using RowsRemoved class to remove records in datagridview But it deleted the following databind record instead of intended record. How to resolve this problem?

ie. username was "ABC" on textbox1.text.
When i deleted "ABC" from datagridview, then textbox1.text captured following value "AAA" but AAA was deleted instead of "ABC"

Seeking for advise and suggestion.

Thank you and Regards.


Code:
Private Sub DataGridView2_RowsRemoved(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewRowsRemovedEventArgs) Handles DataGridView2.RowsRemoved
        'TextBox1 data binded to username
        'TextBox1.DataBindings.Add("Text", dv, "username")

        objCommand.Connection = cn
        objCommand.CommandText = "delete from usertable where username='" & TextBox1.Text & "'"
        objCommand.ExecuteNonQuery()
        MsgBox("deleted")
    End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top