Showing posts with label LINQ TO SQL. Show all posts
Showing posts with label LINQ TO SQL. Show all posts

Thursday, May 1, 2008

USING LINQ TO SQL CLASSES ASP.NET 2008

'USING linq TO SQL TO iNSERT AND bIND GRID ASP.NET 2008


' Ist of all add Linq to sql classes by right click on project and add new item
' Then from server explorer Drag and drop the Database you want to use on the dbml

file u ' added

'then create and object of tht class and use the code below to add and bind gridview

check code below:

Dim db As New DataClassesDataContext '

Dim insemp As New emp
insemp.EName = TextBox1.Text
insemp.Salary = Convert.ToInt32(TextBox2.Text)
db.emps.InsertOnSubmit(insemp)
db.SubmitChanges()

Dim q = From c In db.emps Select c.EName, c.Salary Where Salary >= 1000

GridView2.DataSource = q
GridView2.DataBind()