Tdbgrid not updating data in Delphi

Asked

Viewed 874 times

0

Good morning, I am making a system for a library and on the book search grid that when entering the book id in txtbox it updates and shows the results on the grid, but the grid is not updating and the data remains on the grid and does not change. If anyone knows what thanks is.

    procedure Tfrm_alocar.BitBtn1Click(Sender: TObject);
    var parametro:integer;
    begin

      parametro := strtoint(txt_livro.Text);

      Form_dados.Modulo_Dados.Query_livros.Close;
      Form_dados.Modulo_Dados.Query_livros.sql.Clear;
      Form_dados.Modulo_Dados.Query_livros.sql.Add('select * from livros where id = :parametro');
     Form_dados.Modulo_Dados.Query_livros.Parameters.ParamByName('parametro').Value := parametro;
      Form_dados.Modulo_Dados.Query_livros.Open;

      GridLivros.Update;
      GridLivros.Refresh;

    end;

1 answer

1

I have a hunch what might be going on. You are updating the query_books component. Maybe the grid is connected to a Clientdataset and not to query_books. It is common to link database -> query -> datasetprovider -> clientdataset -> datasource -> dbgrid. If this is the case, you should close in Clientdataset and not in query_books. More or less this:

cds.Close;
qry.ParamByName('parametro').AsInteger := parametro;
cds.Open;
  • blz I will try here more and more or less this msm has connection to sql server database - query of books - dataset

  • well the problem is that this datasource n has the close I will try to migrate pro data set

Browser other questions tagged

You are not signed in. Login or sign up in order to post.