OKIEWARDOYO

VB.NET No.14

Oct 1st, 2013
953
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.84 KB | None | 0 0
  1.     Private Sub ButtonDelete_Click(sender As Object, e As EventArgs) Handles ButtonDelete.Click
  2.         Dim MetuRow As DataGridViewRow
  3.         Dim ID As String
  4.  
  5.         For Each MetuRow In DataGridViewContact.SelectedRows
  6.             ID = MetuRow.Cells(0).Value
  7.         Next
  8.  
  9.         Console.WriteLine("Deleting ID " + ID)
  10.         Try
  11.             Conn = New SqlCeConnection
  12.             Cmd = New SqlCeCommand
  13.             Conn.ConnectionString = MyConString
  14.             Cmd.Connection = Conn
  15.             Cmd.CommandText = "DELETE FROM TableContact WHERE(ID = " + ID + ")"
  16.  
  17.             Conn.Open()
  18.             Cmd.ExecuteNonQuery()
  19.             Conn.Close()
  20.             MessageBox.Show("ID " + ID + " deleted")
  21.             LoadData()
  22.  
  23.         Catch ex As Exception
  24.             MessageBox.Show(ex.ToString)
  25.         End Try
  26.     End Sub
Advertisement
Add Comment
Please, Sign In to add comment