Save, Delete, Search And Update Records in ADO.NET

In this article I am performing simple operations like save, delete, update and search operations in a Windows Forms application. At first we should have a Database. So create a database. In this example my database name is "STUDENT" and database table is "student_detail" which has four columns as "roll_no", "s_name", "age" and "course".

Create a Windows Forms Application. Take some UI controls.

Now we write code to perform the operations described in this article.

Look at the above code. In the first line of code, an instance of a SqlConnection is created. In the next, an instance of a SqlCommand class is created and a SQL statement for inserting values into the database table is specified. Then I am calling the ExecuteNonQuery() method in a try block. In the finally block I am closing the SqlConnection by the Close() method. The same as writing SQL Statements for performing various operations. Look at the following code for performing all the operations.