mash alyy

mash alyy

  • NA
  • 12
  • 5.7k

Deleting record based on name from access database

Jul 25 2012 8:26 AM

hi.
I want to delete a record from access database based on name field.
Db name: stpl
table name:equipments

table name: equipments
field: Mandal,   sal,   Date
eg:    Pune,     2000,  23/7/12
       chennai,  1200,  11/5/12

If i want to delete pune from my record, I just want to press delete button, it should pop-up msgbox asking me to enter Mandal name, And when i enter mandal name: pune, then it shud check with the db whether the record exists, if yes then shud delete it otherwise it shud say:"no record exists"

Try
            Mycn.Open()
            Dim command As String
            command = "delete from Equipments where Mandal='" & txtMan.Text & "';"
            myDA.DeleteCommand.CommandText = command
            myDA.DeleteCommand.ExecuteNonQuery()
            MessageBox.Show("Record deleted")
        Catch ex As Exception
            MessageBox.Show("no record")
        Finally
            Mycn.Close()
        End Try