Recent

Author Topic: problem with tdbgrid reload  (Read 2876 times)

Gebony

  • New Member
  • *
  • Posts: 18
problem with tdbgrid reload
« 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.

valdir.marcos

  • Hero Member
  • *****
  • Posts: 1106
Re: problem with tdbgrid reload
« Reply #1 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

nouzi

  • Sr. Member
  • ****
  • Posts: 296
Re: problem with tdbgrid reload
« Reply #2 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.  
My English is  bad
Lazarus last version free pascal last version
Lazarus trunk  free pascal trunk 
System : Linux mint  64bit  Windows 7 64bit

Gebony

  • New Member
  • *
  • Posts: 18
Re: problem with tdbgrid reload
« Reply #3 on: May 09, 2019, 01:35:18 pm »
Quote
Have you committed your transaction before reloading your data?
of course i have committed it.

Gebony

  • New Member
  • *
  • Posts: 18
Re: problem with tdbgrid reload
« Reply #4 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.

nouzi

  • Sr. Member
  • ****
  • Posts: 296
Re: problem with tdbgrid reload
« Reply #5 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
My English is  bad
Lazarus last version free pascal last version
Lazarus trunk  free pascal trunk 
System : Linux mint  64bit  Windows 7 64bit

valdir.marcos

  • Hero Member
  • *****
  • Posts: 1106
Re: problem with tdbgrid reload
« Reply #6 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.

nouzi

  • Sr. Member
  • ****
  • Posts: 296
Re: problem with tdbgrid reload
« Reply #7 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
My English is  bad
Lazarus last version free pascal last version
Lazarus trunk  free pascal trunk 
System : Linux mint  64bit  Windows 7 64bit

Gebony

  • New Member
  • *
  • Posts: 18
Re: problem with tdbgrid reload
« Reply #8 on: May 10, 2019, 01:21:52 pm »
I am rewriting the project with datamodule object and I will try it

Gebony

  • New Member
  • *
  • Posts: 18
Re: problem with tdbgrid reload
« Reply #9 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

Gebony

  • New Member
  • *
  • Posts: 18
Re: problem with tdbgrid reload
« Reply #10 on: May 20, 2019, 02:20:23 pm »
thanks for all.I have solved it.

 

TinyPortal © 2005-2018