Recent

Author Topic: component list to database  (Read 2226 times)

secretk

  • New Member
  • *
  • Posts: 10
component list to database
« on: August 14, 2018, 05:27:20 pm »
Hi All,

Im very new to Lazarus pascal and need a bit of help

I found this piece of code:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button5Click(Sender: TObject);
  2.   var
  3.   i: Integer;
  4.   list: string;
  5. begin
  6.   for i := 0 to ComponentCount-1 do
  7.     list:=list+#10#13+Components[i].Tag.ToString;
  8.  
  9.   ShowMessage('We can also list all the components in the form without knowing their names:'+list);
  10. end;

It works fine but can someone help me how to put this (List) information in a MySql database table?
(I use Zeos Access for database connection)

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: component list to database
« Reply #1 on: August 14, 2018, 06:19:40 pm »
To be honest I do not understand your code. Why do you need the "Tag" of the components?

In the attachment you can find a quick and dirty demo how to iterate through the components on a form and to write their names to a listbox or to a sqlite3 database (sorry I don't have access to MySQL, but the code should be very similar).


secretk

  • New Member
  • *
  • Posts: 10
Re: component list to database
« Reply #2 on: August 14, 2018, 06:28:42 pm »
Thxs wp for the fast reply

The reason i need the "Tag" is to be able to setup a users roles and rights in the database based of something specific to the component.

based on the tag i will try to add specific CRUD settings to the database
based on those settings trying to give specific access to the components within the form.

If someone has a better idea i'm open for it.

In your example your using "Name" but that won't work for me because i need a unique identifier for a group of components.

Example would be; If components DBgrid1 and DBgrid2 has tag "1" then they have CRUD access and if DBgrid3 has tag "2" then it had CRU access.
« Last Edit: August 14, 2018, 06:43:12 pm by secretk »

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: component list to database
« Reply #3 on: August 14, 2018, 09:29:10 pm »
Your question was about how to save a list of the components on a form in a database. I did not care about the details of your application which I don't know. I only selected the component name, but if you understand the idea behind the demo you will be able to extend it to other properties such as the "Tag".

 

TinyPortal © 2005-2018