Ichikuma's blog

生活實況紀錄

By

dasblog upgraded to 2.0.7226.0

Now my current version dasBlog is 2.0.7226.0. 🙂

By

Bind DLINQ to DataGridView

This morning I try to find a method to bind DLINQ to DataGridView. There don’t have ToBindingList in DLINQ DataQuery. Need to manually import System.Data.Dlinq.DataQueryExtensions in the top of form

	Imports System.Data.Dlinq.DataQueryExtensions

After that, the method ToBindingList() will come out.

        Dim sConnectString As String = "data source=.\SQLEXPRESS;" & _
                 "Integrated Security=SSPI;AttachDBFilename=D:\Data\Northwind.mdf;" & _
                 "User Instance=true"
        Dim db As New Northwind(sConnectString) 

        Dim cust = From c In db.Customers _
                 Select c

        DataGridView1.DataSource = cust.ToBindingList()
        DataGridView1.Refresh()

So now, I can modify this to bind the DataQuery to BindingSource for my form.