How to Delete and Retrieve Data in C# and SQL Server 2005


deleteandretrieveSQLOPIThis time, I will teach you how to delete and retrieve the data in and SQL server 2005. Deleting records are not advisable to a system, however, in developing a system, you have to put a “delete” method so that, it will be easy for you to remove whatever data that you have saved in the database for the input testing.


So, let’s get started:


  • Create a database and name it “testdb”.
  • Open Microsoft Visual Studio 2008 and create new Windows Form Application.
  • Do the Form as follows.


  • Go to the Solution Explorer, click the “View Code”  to display the code editor.


  • Declare all the classes and variable that are needed.

Note: Put using System.Data.SqlClient; above the namespace to access sql server library.

  • Go back to the design view, double-click the Form and do the following codes for the connection between C# and SQL server.

  • Create a method for retrieving the records in the database to the DataGridView.

  • Go back to the design view, double-click a button and do the following codes for deleting the records in the SQL database.





For all students who need a programmer for your thesis system or anyone who needs a source code in any programming languages. You can contact me @ :
Email – [email protected]
Mobile No. – 09305235027 – tnt


Download Sourcecode

Looking for more source code? Type your keyword here here!


Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.