Lazarus

Free Pascal => Database => Topic started by: Gebony on May 08, 2019, 06:00:32 pm

Title: problem with tdbgrid reload
Post by: Gebony on May 08, 2019, 06:00:32 pm
please help;
I have tried to reload data from database after adding or deleting or updating data but no use. I have tried these codes:
1-
     sqlquery.close;
     sqlquery.open;
2-
    sqlquery.sql.clear;
    sqlquery.sql.text:='select * from table';
    sqlquery.open;
3-
    dbgrid.datasource.dataset.refresh;
4-
    sqlquery.active:=false;
    sqlquery.active:=true;

these all codes not working and I must close the app and run it again to reload the new data.
Title: Re: problem with tdbgrid reload
Post by: valdir.marcos on May 09, 2019, 08:51:04 am
please help;
I have tried to reload data from database after adding or deleting or updating data but no use. I have tried these codes:
1-
     sqlquery.close;
     sqlquery.open;
2-
    sqlquery.sql.clear;
    sqlquery.sql.text:='select * from table';
    sqlquery.open;
3-
    dbgrid.datasource.dataset.refresh;
4-
    sqlquery.active:=false;
    sqlquery.active:=true;

these all codes not working and I must close the app and run it again to reload the new data.
Have you committed your transaction before reloading your data?
http://wiki.freepascal.org/SQLdb_Programming_Reference
http://wiki.lazarus.freepascal.org/SqlDBHowto
Title: Re: problem with tdbgrid reload
Post by: nouzi on May 09, 2019, 12:07:42 pm
try tihs
Code: Pascal  [Select][+][-]
  1.  
  2. procedure TDataModule1.NametableAfterPost(DataSet: TDataSet);
  3. begin
  4.    Nametable.Refresh;
  5. end;  
  6.  
  7.  
Title: Re: problem with tdbgrid reload
Post by: Gebony on May 09, 2019, 01:35:18 pm
Quote
Have you committed your transaction before reloading your data?
of course i have committed it.
Title: Re: problem with tdbgrid reload
Post by: Gebony on May 09, 2019, 01:36:59 pm
try tihs
Code: Pascal  [Select][+][-]
  1.  
  2. procedure TDataModule1.NametableAfterPost(DataSet: TDataSet);
  3. begin
  4.    Nametable.Refresh;
  5. end;  
  6.  
  7.  
I haven't used datamodule.
Title: Re: problem with tdbgrid reload
Post by: nouzi on May 09, 2019, 06:15:34 pm
try tihs
Code: Pascal  [Select][+][-]
  1.  
  2. procedure TDataModule1.NametableAfterPost(DataSet: TDataSet);
  3. begin
  4.    Nametable.Refresh;
  5. end;  
  6.  
  7.  
  8.  
I haven't used datamodule.


Change to what suits your code
Name form example
Title: Re: problem with tdbgrid reload
Post by: valdir.marcos on May 09, 2019, 07:32:34 pm
Quote
Have you committed your transaction before reloading your data?
of course i have committed it.
Please, upload a sample project with sample data so we can help you better.
Title: Re: problem with tdbgrid reload
Post by: nouzi on May 09, 2019, 07:51:58 pm
try tihs
Code: Pascal  [Select][+][-]
  1.  
  2. procedure TDataModule1.NametableAfterPost(DataSet: TDataSet);
  3. begin
  4.    Nametable.Refresh;
  5. end;  
  6.  
  7.  
  8.  
I haven't used datamodule.


Change to what suits your code
Name form example
Title: Re: problem with tdbgrid reload
Post by: Gebony on May 10, 2019, 01:21:52 pm
I am rewriting the project with datamodule object and I will try it
Title: Re: problem with tdbgrid reload
Post by: Gebony on May 13, 2019, 12:22:22 pm
I wrote the code of loading data in formactivate event and i call it from any form.
but there is new problem when i call the field id  appear a message "field not found"
Code: Pascal  [Select][+][-]
  1. dbgrid1.datsource.dataset.fieldbyname('id').asinteger
Title: Re: problem with tdbgrid reload
Post by: Gebony on May 20, 2019, 02:20:23 pm
thanks for all.I have solved it.
TinyPortal © 2005-2018