.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> Windows Form Controls >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Delete Record From Database

Posted By:Ghanashyam Nayak       Posted Date: January 31, 2011    Points: 15    Category: Windows Form Controls    URL: http://www.dotnetspark.com  

Code To Delete Record From Database...
 


Public Sub DeleteRecord()
	Dim Conn As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:/MyDatabase1.mdb")
	Try
            		Conn.Open()
            		Dim cmd As OleDbCommand = New OleDbCommand("DELETE FROM Student WHERE StudentId=" + txtStudentId + ";", Conn)
            		cmd.ExecuteNonQuery()
            		MessageBox.Show("Data Deleted Successfully From Database.")
        	Catch ex As Exception
            		MessageBox.Show(ex.ToString())
        	Finally
            		Conn.Close()
        	End Try
End Sub


     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend