Click here to Skip to main content
15,905,229 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
I want to fill dataset using linq object to the example In Microsoft's site:

example

' Fill the DataSet. 
Dim ds As New DataSet()
ds.Locale = CultureInfo.InvariantCulture
' See the FillDataSet method in the Loading Data Into a DataSet topic.
FillDataSet(ds)

Dim products As DataTable = ds.Tables("Product")

Dim query = From product In products.AsEnumerable() _
            Select product.Field(Of String)("Name")

Console.WriteLine("Product Names:")
For Each productName In query
    Console.WriteLine(productName)
Next


The FillDataSet (ds) did not implement the source? What was the code should be?

or

How to fill a dataset because all the examples of FillDataSet not implement this method in linq ?
Posted
Updated 21-Apr-14 0:36am
v2

C#
' Fill the DataSet. 
Dim ds As New DataSet()
ds.Locale = CultureInfo.InvariantCulture
' See the FillDataSet method in the Loading Data Into a DataSet topic.
FillDataSet(ds)

Dim products As DataTable = ds.Tables("Product")

Dim query = From product In products.AsEnumerable() _
            Select product
Console.WriteLine("Product Names:")
For Each p In query
    Console.WriteLine(p.Field(Of String)("Name"))
Next
 
Share this answer
 
v3
Hi,

You need to review below links, which will help you to understand implementation for the same.

LINQ to DataSet Examples[^]

VB.NET Using LINQ to Query DataTable and Bind to Gridview[^]
 
Share this answer
 
have you read that page?


The FillDataSet method used in these examples is specified in Loading Data Into a DataSet[^].
 
Share this answer
 
Comments
zehs_sha 21-Apr-14 8:35am    
yes ! but that page read data with ado.net
Step 1:
You must create a dataclass and insert your table. Suppose, Dataclass_name="MyDataClass" & table_Name="Table1"

Step 2:
You this code:
VB
dim _db as new MyDataClass
dim q = From i in  _db.Table1 
DataGridView1.DataSource = q.ToList


Step 3:
Run & Enjoy it!
 
Share this answer
 
Comments
zehs_sha 24-Apr-14 5:38am    
and how fill dataset ?please

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900