Recent

Author Topic: create a unit with a procedure  (Read 1635 times)

Glewins

  • New member
  • *
  • Posts: 8
create a unit with a procedure
« on: December 25, 2018, 02:08:27 am »
I use Win 10, Laz 1.8.2, FPC 3.04, Zeos 2.4...

What I would like to do Is create a unit, that has a procedure that populates a dbgrid or fields.

example 

on formshow event, I call Populatemydb(dm.dmod.QSE, thesqltext:stringg);

in unit a procedure called populatemydb(Thequery:tzquery, 'SELECT * FROM EMPLOYEE order by EMPID );

PopulatemydbThe query:tzquery);
begin
 try
   if not thequery.active then thequery.Active := true;
   thequery.sql.text := thresqltext;
  thequery.open;
 Except
  on e:exception do
    begin
      showmessage(E.Message+'Error in Executing SQL '+thesqltext+'!');
     end;
   end;
Finally
  // do something else
end;

I have used this with Delphi and Absolutedb, but no luck with Zeos & Firebird and Lazarus.

George

Thaddy

  • Hero Member
  • *****
  • Posts: 10606
Re: create a unit with a procedure
« Reply #1 on: December 25, 2018, 10:35:04 am »
If it works in Delphi it should also work in Lazarus. Not enough information to help you.

mangakissa

  • Hero Member
  • *****
  • Posts: 1101
Re: create a unit with a procedure
« Reply #2 on: December 25, 2018, 10:49:04 am »
This is really a standard procedure that works even in older verions.

What's the problem
Lazarus 2.06 (64b) / FPC 3.0.4 / Windows 10
stucked on Delphi 10.3.1

MacWomble

  • Jr. Member
  • **
  • Posts: 77
Re: create a unit with a procedure
« Reply #3 on: December 25, 2018, 01:01:22 pm »
If this is your source-code then it never will run.

Please copy and paste and use format 'code' for this.
Mint 19.3 Cinnamon, FPC/ Lazarus Trunk 64Bit

Glewins

  • New member
  • *
  • Posts: 8
Re: create a unit with a procedure
« Reply #4 on: December 26, 2018, 07:01:50 pm »
You are right.  It won't run.  I have solved the problem. I sat down with pencil and paper and thought about what I wanted,
did not take long.  Just needed to see the whole picture.  Thanks.  George.

 

TinyPortal © 2005-2018