0

I have a DataGridView with a source of DataSet filled by Adapter using data from Database. Now I want to query the DataSet with closed connection. What is the query to search a specific record?

This is the code that fetches all customers:

private void button2_Click(object sender, EventArgs e)
{
    DataSet CustList = new DataSet();
    CustList = gt.GetCustomers();
    dataGridView1.AutoGenerateColumns = false;
    dataGridView1.DataSource = CustList.Tables[0];
}

What will be done to query this DataSet CustList and throw the results back in the same DGV, Thanks.

Dhaval Asodariya
  • 558
  • 5
  • 19

1 Answers1

0

Try this..

var results = from myRow in myDataTable.AsEnumerable()
where myRow.Field<int>("RowNo") == 1
select myRow;

[Reference]

Dhaval Asodariya
  • 558
  • 5
  • 19