Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

deleting a record based on name from aceess db

mashalyymashalyy Posts: 2Member
I want to delete a particular record based on name from access database in

db name: stpl
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".

My code is: here I used textbox, actually i want to use pop-up box.
Iam getting error: object ref set not to instance of an object.

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

I tried this code also:

Mycn = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & System.Environment.CurrentDirectory & "STPL.accdb")
Dim sql As String
sql = "Delete from Equipments where Mandal=" & Convert.ToString(txtMan.Text) & ""
command = New OleDbCommand(sql, Mycn)
MessageBox.Show("Record Deleted Successfully", "Deleting Employee Details", MessageBoxButtons.OK, MessageBoxIcon.Warning)
Catch ex As OleDbException
MessageBox.Show("Please enter Name only", "Deleting Employee Details", MessageBoxButtons.OK, MessageBoxIcon.Error)
Catch ex As Exception
MessageBox.Show("Please enter Name only", "Deleting Employee Details", MessageBoxButtons.OK, MessageBoxIcon.Error)

End Try

But no use.........
help me out

Sign In or Register to comment.