aarontham
asked on
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.
i need code in vb.net 2008 to do select query in datatable and display in datagridview.
sorry forgot to add you can use filter for the same effect as doing a select.
bindSource.Filter = "MyColumnName > 5";
bindSource.Filter = "MyColumnName > 5";
You can also perform a linq-query to get your result from the datatable into your datagridview.
Example:
Dim Query = From i In YourDataTable.AsEnumerable () _
Where i.Field(Of String)("YourField") = "Status"
DataGridView_Customer.Data Source = Query.AsDataView()
Example:
Dim Query = From i In YourDataTable.AsEnumerable
Where i.Field(Of String)("YourField") = "Status"
DataGridView_Customer.Data
ASKER
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) & "%'")
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 & "%")
Where SqlMethods.Like(i.CusName,
ASKER
hi Dhaest,
Do work. have error on SqlMethods
it say SqlMethods not declare and Where not declare.
Do work. have error on SqlMethods
it say SqlMethods not declare and Where not declare.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
DataSet1 ds = new DataSet1();
BindingSource bindSource = new BindingSource();
bindSource.DataSource = ds;
bindSource.DataMember = "DataTable1";
this.dataGridView1.DataSou