Skip and Take in Linq to Sql in VB.Net
By bryan tugade
We could get specific rows in the database table by skip and take using Linq to Sql. Here is the sample code.
Partial Class _Default
Private Sub GetData(ByVal iSkip As Integer, ByVal itake As Integer)
Dim sqldatacontext = New linqtosqlclassDataContext
Dim data = (From product In sqldatacontext.Products Where Product.Color = "Black" Skip iSkip Take itake Select product)
GridView1.DataSource = data
Use the AdventureWorks as the sample database. Just call the sub procedure and pass
an integer to its parameter.
i.e. GetData(5,10) where 5 is the rows that you want to skip and 10 is the row that
you only wanted to show in the result.
In C#, we can select and deselect checkbox in gridview in onPostback event of checkbox in gridview header.
We can select multiple fields in a given database tables using Linq to sql. I use AdventureWorks as my database in this sample app and to show you how it works i bind the results in gridview control.
We can filter data using dataview.
Assuming that you need to create an application that needs to transfer data from sql server to microsoft excel. The first thing you need to do is to find a way to connect to sql server. We can do this by using visual basic application.
We can easily bind gridview using linq to sql. Assuming that your using AdventureWorks as your database.
Skip and Take in Linq to Sql in VB.Net (936 Views)