Hello. How to update DataTable after searching the table? I type the names FbDataAdapter and DataTable without a variable name so that it is clearer. For example, there was a request at the beginning of the download.

SELECT * FROM "ТАБЛИЦА" 

Data is displayed correctly (using FbDataAdapter.Fill)
But when I perform a search with the query FbDataAdapter.SelectCommand.CommandText, for example

 FbDataAdapter.SelectCommand.CommandText = "SELECT * FROM \"ТАБЛИЦА\" WHERE \"Код\" LIKE '%123%'"; 

and then,

  FbDataAdapter.SelectCommand.ExecuteNonQuery(); FbDataAdapter.Fill(DataTable); 

That sample is obtained, but the old data does not disappear anywhere, i.e. This sample is added to them, for example, 2 records. I tried before sampling:

  DataTable.Clear(); 

DataTable is cleared, but after selection only one record is output, although through the same IBExpert, the same query displays, for example, 2 records.

How to properly implement this so that after the second query the DataTable is updated correctly? Thank.

    1 answer 1

    Problem solved. First, assign the component

      DataGridView.DataSource = null; 

    Then, after operations with the DataTable, we again assign the changed DataTable to the DataGridView.DataSource.