vb.net 2008 select query in datatable and display in datagridview

I already have datatable fill with data.
i need code in vb.net 2008 to do select query in datatable and display in datagridview.
Who is Participating?
DhaestConnect With a Mentor Commented:
Imports System.Linq
Imports System.Data.Linq.SqlClient

        Dim TextBox38 As TextBox = New TextBox
        TextBox38.Text = ""

        Dim rsName As New DataTable
        rsName.Columns.Add(New DataColumn("CusName"))
        Dim Query = From i In rsName.AsEnumerable() _
         Where SqlMethods.Like(i("CusName"), "%" & TextBox38.Text & "%")
I only have c# installed here but it should be easy to port from:

 DataSet1 ds = new DataSet1();
 BindingSource bindSource = new BindingSource();
 bindSource.DataSource = ds;
 bindSource.DataMember = "DataTable1";
 this.dataGridView1.DataSource = bindSource;
sorry forgot to add you can use filter for the same effect as doing a select.

bindSource.Filter = "MyColumnName > 5";
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

You can also perform a linq-query to get your result from the datatable into your datagridview.

Dim Query = From i In YourDataTable.AsEnumerable() _
         Where i.Field(Of String)("YourField") = "Status"

DataGridView_Customer.DataSource = Query.AsDataView()

aaronthamAuthor Commented:
hi Dhaest:

i don't understand on the Query part. below is my code help to modify to use your code.

Public rsName As New DataTable
Dim custRows() As DataRow = rsName.Select("CusName like  '%" & (TextBox38.Text) & "%'")
Dim Query = From i In rsName.AsEnumerable() _
         Where SqlMethods.Like(i.CusName, "%" & TextBox38.Text & "%")
aaronthamAuthor Commented:
hi Dhaest,

Do work. have error on SqlMethods

it say SqlMethods not declare and Where not declare.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.