Home » Tutorials » ASP.NET » Select, Insert, Update, Delete-CRUD operation using Linq to Sql classes in asp net

Select, Insert, Update, Delete-CRUD operation using Linq to Sql classes in asp net

getElementById vs getElementsByName vs getElementsByTagName
Inserting bulk records using JavaScript, asp.net

This article is help to create new website having crud operation using linq to sql classes in asp net.It also explains step-by-step implementation of LINQ to SQL class for CRUD operations.

What Is LINQ To SQL?

Full meaning of LINQ is ‘Language Integrated Query’, which replaces the traditional sql query execution process. Moreover, it doesn’t only applicable to manipulate database results, but it can also be used to manipulates array/list collections. Linq was released as part of the .NET framework 3.0 and can be used from languages supported by .NET framework like C#, VB etc. The term ‘LINQ To SQL‘ refers to the technology by which we can use LINQ for access SQL Databases. Here in this tutorial, I will show step by step ways to get started with LINQ To SQL programming with C#.

Steps to implement LINQ to SQL:

Step 1: Create database “StudentDB”

Step 2: Create table Student

In student table set ‘StudentID’ as primary key

 as in below screen shot:


Step 3:

Now start visual studio 2012

File->> New Website

Provide name of website set location and Click ‘OK’ as shown in below screen shot:


Step 4:

Right click on Website and Add new item select “LINQ to SQL Classes”


when we click “Add” button we will get message like below :


Click “Yes” , then see in your project one folder name “App_code” will be created with “DataClasses.dbml” file name

Step 5:

Open “DataClasses.dbml” file. Explore database “StudentDb” and select “Student” table and drag & drop it to “DataClasses.dbml” like shown below:


This will add a connection string in “Web.config” file


Step 6:

Right-click on the project file and select “Add New Item…”.

Select “Web Form” from the templates.

Give the name as “Default .aspx”.

Press the “Add” button.

This will add a Default.aspx page to your website’s root directory.

Step 7:

Now add the following code in your Default.aspx page under the “form” control:


Step 8: Now add the following code to your Default.aspx.cs file:


Step 9: Now run website


Download sample of Select,Insert, Update and Delete Functionality with LINQ to SQL in asp.net

Conclusion : Here I have explained Select,Insert, Update and Delete Functionality with LINQ to SQL in asp.net


Leave a Reply

Your email address will not be published. Required fields are marked *


Time limit is exhausted. Please reload CAPTCHA.

The content is copyrighted to technothirsty.com and may not be reproduced on other websites without permission from the owner.You may contact us using the information below.