none
Multiple deletion of the database RRS feed

  • Question

  • I have a database and I delete a row by choice
    1- I want to delete multiple rows where I chose(multiple sellect) them
    2-Delete multiple rows where there is a cell checking for the row

    code - delete a row by choice

     Try
                If DataGridView1.RowCount <= 0 Then
                    Exit Sub
                End If
                Dim I As Integer = DataGridView1.CurrentCell.RowIndex
                con.Open()
                Dim cmd = New OleDbCommand("DELETE FROM tb1 where ID_mail like " & DataGridView1.Rows(I).Cells(0).Value & " and clien_mail like '" & DataGridView1.Rows(I).Cells(1).Value.ToString & "'", con)
                cmd.ExecuteNonQuery()
                con.Close()
                DataGridView1.Rows.RemoveAt(DataGridView1.CurrentRow.Index)
            Catch ex As Exception
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            End Try

    Friday, January 12, 2018 7:01 PM