aspx Tutorial

.NET Articles,jQuery demo, asp.net with jQuery, online tutorial,Jquery, SilverLight, Javascript, asp.net,JSON, MVC,.NET Articles,demo, Web Services, .NET articles, Sharepoint 2010, visual studio 2010,Aamir Hasan,IT, Building Your First Web Application Project
Advertise Here

Toolbar

Get our toolbar!

Advertize



Posted by Aamir Hasan   on Wednesday, February 22, 2012 Total Views:  

In this example you will see how to insert record in database using linq. Create a DataClasses.dbml file. Open DataClasses.dbml file. Open Server Explorer and connect to database. Expand Tables node and drag and drop your table. I have used Patient table in my database. The following code will add new patient record into patient table in SQL Server.

 

        using (var db = new DataClassesDataContext())

         {

            var addPat = new PATIENT { NAME = "Aamir Hasan" };

            db.PATIENTs.InsertOnSubmit(addPat);

            db.SubmitChanges();

        }

 

Note: Table should have primary key, otherwise it will through invalid operation exception.

Category: All | asp.net | Linq
Protected by Copyscape Online Plagiarism Tool

Comments (1) -

ACE PDF
ACE PDF United States
8/13/2012 9:13:08 PM #

I am thoroughly impressed by the way you present your article, information and the ability to give unknown facts is the most surprising factor of all. This article looks very good.

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading

Advertizement 1
Advertizement 2
Advertizement 3
Advertizement 4
Advertizement 5