Recent

Author Topic: DBLookupCombobox problem when create on the fly and post reccord  (Read 806 times)

rmmm

  • Newbie
  • Posts: 2
Hi Everyone here,

I have a problem and attachement a simple project to ilustrate it.

When i create "on the fly", after post, the  component inactive :(
If i use component from form, all is OK.  :o
Can someone advise, where's my fault?
Thanks!


Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormCreate(Sender: TObject);
  2. var
  3. SQL1:TSQLQuery;
  4. DTS1:TDataSource;
  5. begin
  6.  
  7.   with MySQL56Connection1 do begin
  8.  
  9.      HostName:='localhost';
  10.      UserName:=''; //'user24';
  11.      Password:=''; //'2024';
  12.      DataBaseName:='db24';
  13.      Connected:=True;
  14.   end;
  15.  
  16.   SQLTransaction1.Active:=True;
  17.  
  18.   with SQLQuery1 do begin
  19.      SQL.Text:='select * from art';
  20.      Open;
  21.   end;
  22.  
  23. // {
  24.  
  25. // OPTION I: WORK FINE
  26.  
  27. with SQLQuery2 do begin
  28.    SQL.Text:='select * from fam order by fam_nom';
  29.    Open;
  30.    DBLookupComboBox1.ListSource:=DataSource2;
  31. end;
  32.  
  33. // }
  34.  
  35. //
  36. {
  37. // OPTION II:  "After update and post"  component DBLookupComboBox1 "DISABLED";
  38.  
  39.   with SQL1 do begin
  40.      SQL1:=TSQLQuery.Create(Self);
  41.      Database:= SQLQuery1.DataBase;
  42.      Transaction:=SQLQuery1.Transaction;
  43.      SQL.Text:='select * from fam order by fam_nom';
  44.      Open;
  45.  
  46.      DTS1:=TDataSource.Create(Self);
  47.      DTS1.DataSet:=SQL1;
  48.  
  49.  
  50.      DBLookupComboBox1.ListSource:=DTS1;
  51.  
  52.      SQL1:=nil;
  53.      DTS1:=nil;
  54.  
  55. end;
  56. // }
  57. end;                
  58.  
  59.  

rmmm

  • Newbie
  • Posts: 2
Re: DBLookupCombobox problem when create on the fly and post reccord
« Reply #1 on: August 09, 2024, 01:38:07 pm »
Hi

All components link to this SQL1 is disabled after update other SQL

Repair it.

thanks a lot.



Code: Pascal  [Select][+][-]
  1.  
  2.   with SQL1 do begin
  3.      SQL1:=TSQLQuery.Create(Self);
  4.      SQL1.Database:= SQLQuery1.DataBase;
  5.      Transaction:=SQLQuery1.Transaction;
  6.  
  7.      SQL1.AfterClose:=@SQLQueryAfterClose;  // <------- HERE
  8.  
  9.      SQL.Text:='select * ...
  10.     Open;
  11. ....
  12.  

Code: Pascal  [Select][+][-]
  1. procedure TForm1.SQLQueryAfterClose(DataSet: TDataSet);
  2. begin
  3.   DataSet.Active:=True;
  4. end;
  5.  

 

TinyPortal © 2005-2018