Recent

Author Topic: How can I connect a Database to Datasource1 ?  (Read 18497 times)

Lupo

  • Guest
How can I connect a Database to Datasource1 ?
« on: May 17, 2004, 09:51:28 pm »
Hi !
I'd like to use the database-components in lazarus. How do you connect a Datasource-Control with a database? Which database-format would you prefer?
Many thanks!
Lupo  :shock:

jesusr

  • Sr. Member
  • ****
  • Posts: 484
How can I connect a Database to Datasource1 ?
« Reply #1 on: May 18, 2004, 05:01:48 am »
You need to compile some dataset components for example: TDbf, its simple and you dont need to install and setup a dbengine as MySQL or Firebird, but there are components for these too.

The steps to compile components vary depending if you are in linux or windows.

If you already compiled Tdbf component, then it's easy:

1. Drop a TDbf component
2. Drop a TDataSource Component
3. Drop some DataAware componentes: TDbEdit, TDbNavigator, TDbGrid (not very nice at the moment :(, all components need testing so bugs can be fixed ;) ), etc.
4. Wire everything
5. Open the dataset at runtime ( not a design time!). For ex:

   procedure Form1.FORMCREATE(sender: TObject)
    begin
      dbf1.Open;
    end;

Jesus Reyes A.

Anonymous

  • Guest
How can I connect a Database to Datasource1 ?
« Reply #2 on: May 18, 2004, 11:52:23 pm »
Thanks a lot.
It seems to be difficult for a newbee like me. But I'll try it. Report later.

Lupo  :D

Anonymous

  • Guest
How can I connect a Database to Datasource1 ?
« Reply #3 on: June 16, 2004, 10:44:45 pm »
Can you give an example of what you enter in the DataSet property of the TDataSource?

jesusr

  • Sr. Member
  • ****
  • Posts: 484
How can I connect a Database to Datasource1 ?
« Reply #4 on: June 16, 2004, 11:17:17 pm »
Quote from: "Anonymous"
Can you give an example of what you enter in the DataSet property of the TDataSource?
Once you get a TDataSet component descendant compiled, for example TDBF with the above procedure (it will appear in the Data Access tab in the component palette), it's just a matter of droping a TDbf component on the form, it will be assigned a name for example tdbf1, then select the TDataSource component and in the Object inspector select the Dataset Property, this would be a combobox list. In this list there should be listed the tdbf1 component, select it and ready. they are now linked.

in the tdbf1 component remember to set the RunTimePath to the place you store the db files, and TableName to the name of the dbf file you want to open.

Then in the FormCreate Event, write something like
Code: [Select]

   tdbf1.Active := true.

I think this is all to wire the non visual database components.

jesusr

  • Sr. Member
  • ****
  • Posts: 484
How can I connect a Database to Datasource1 ?
« Reply #5 on: June 16, 2004, 11:45:52 pm »
Quote from: "jesusr"
Quote from: "Anonymous"
Can you give an example of what you enter in the DataSet property of the TDataSource?
Once you get a TDataSet component descendant compiled, for example TDBF with the above procedure (it will appear in the Data Access tab in the component palette), it's just a matter of droping a TDbf component on the form, it will be assigned a name for example tdbf1, then select the TDataSource component and in the Object inspector select the Dataset Property, this would be a combobox list. In this list there should be listed the tdbf1 component, select it and ready. they are now linked.

in the tdbf1 component remember to set the RunTimePath to the place you store the db files, and TableName to the name of the dbf file you want to open.

Then in the FormCreate Event, write something like
Code: [Select]

   tdbf1.Active := true.

I think this is all to wire the non visual database components.


Oops, it seems there is no compile component procedure above, sorry.
Quick procedure:
1.- Open the component packages using menu: Components->Open Package File
     and select the file, there are some components under lazarus->components directory
     the file is the one ending with .lpk
2.- Press "compile" and then "Install" a dialog will appear to accept rebuild lazarus. press the "yes" button.
3.- restart Lazarus.
4.-Play with those components and report bugs in the bug tracking system or in the mailing list.

NOTE: in windows, before opening lazarus, rename lazarus.exe to laz.exe for example, and run the laz.exe file or else lazarus.exe cannot be replaced. So between steps 2 and 3 add step 2.5: delete the laz.exe (if everything went ok ;)

Anonymous

  • Guest
How can I connect a Database to Datasource1 ?
« Reply #6 on: June 17, 2004, 08:56:15 pm »
Thanks for your help Jesusr, but now I have another problem:
when I click "Yes" to rebuild Lazarus absolutely nothing happens.
I have renamed Lazarus.exe to Laz.exe as you suggested, I have checked the options to make sure I'm pointing to the correct directory for the compiler, none of my directory names have spaces in them.
I am running Windows XP.
Do you have any idea what's going wrong?

Thanks again...
Steve  :(

Anonymous

  • Guest
How can I connect a Database to Datasource1 ?
« Reply #7 on: June 18, 2004, 12:48:11 am »
Please, where can I get a TDataSet component descendant compiled, for example TDBF?

Tanks.

Ademir

jesusr

  • Sr. Member
  • ****
  • Posts: 484
How can I connect a Database to Datasource1 ?
« Reply #8 on: June 18, 2004, 02:10:25 am »
Quote from: "Anonymous"
Thanks for your help Jesusr, but now I have another problem:
when I click "Yes" to rebuild Lazarus absolutely nothing happens.
I have renamed Lazarus.exe to Laz.exe as you suggested, I have checked the options to make sure I'm pointing to the correct directory for the compiler, none of my directory names have spaces in them.
I am running Windows XP.
Do you have any idea what's going wrong?

Thanks again...
Steve  :(


Check your Environment Path variable, it should include the directory to the gnu compiling tools: make, as, ar, etc.
I use the following:
 Set PATH=c:\pp19\bin\win32;C:\pp\bin\win32
in the pp19\bin\win32 I have the compiler and in pp\bin\win32 all the tools needed.

A dump of your lazarus output would be useful:
1. Open a msdos window and cd to the lazarus install, ex: cd c:\lazarus
2. start lazarus as: laz > output.txt and try to compile the component
3. send the output.txt or if it too large, open with your favorite text editor and strip some parts.

jesusr

  • Sr. Member
  • ****
  • Posts: 484
How can I connect a Database to Datasource1 ?
« Reply #9 on: June 18, 2004, 02:16:04 am »
Quote from: "Anonymous"
Please, where can I get a TDataSet component descendant compiled, for example TDBF?

Tanks.

Ademir


There are some under the:
lazarus_install_dir->components directory

TDbf is under lazarus>components>tdbf

all components have the .lpk extension.

so doing a search for *.lpk starting in the lazarus directory should show all component packages in the lazarus directory.

jesusr

  • Sr. Member
  • ****
  • Posts: 484
How can I connect a Database to Datasource1 ?
« Reply #10 on: June 18, 2004, 02:57:15 am »
Quote from: "jesusr"
Quote from: "Anonymous"
Please, where can I get a TDataSet component descendant compiled, for example TDBF?

Tanks.

Ademir


There are some under the:
lazarus_install_dir->components directory

TDbf is under lazarus>components>tdbf

all components have the .lpk extension.

so doing a search for *.lpk starting in the lazarus directory should show all component packages in the lazarus directory.


Maybe I misunderstood the question, are you asking for an already compiled component?. This is not the way how Lazarus works, you have to link the components so they are part of the Lazarus compiling process.

dynamically loading components is not yet supported.

Anonymous

  • Guest
How can I connect a Database to Datasource1 ?
« Reply #11 on: June 19, 2004, 11:09:16 pm »
From Output.txt:

This is at the start of Output.txt:
NOTE: editor options config file not found - using defaults
NOTE: codetools config file not found - using defaults


This message suggests it compiled the package ok:
TOutputFilter: "30233 Lines compiled, 12.0 sec"
TOutputFilter: ""Compiling package TurboPowerIPro 1.0" completed"


but then this is what happens when I say yes to install:
TPkgManager.SaveAutoInstallDependencies A TurboPowerIPro
TPkgManager.SaveAutoInstallDependencies A MySQLLaz
TPkgManager.SaveAutoInstallDependencies A DBFLaz
TPkgManager.SaveAutoInstallDependencies A SDFLaz


It's obvious from the list it remembers what I've asked for each time I've tried to install components but nothing happens When I click "Yes".

I guess this is me shutting lazarus down:
TMainIDE.DoCloseEditorFile A PageIndex=0
TCustomFormEditor.DeleteControl TForm1 TRUE
TPascalParserTool.BuildTree B OnlyIntf=FALSE  project1.lpr
TPascalParserTool.BuildTree B OnlyIntf=FALSE  project1.lpr
TMainIDE.DoCloseEditorFile end
LAZARUS END - cleaning up ...
[TMainIDE.Destroy] A
[TMainIDE.Destroy] B  -> inherited Destroy...
[TMainIDE.Destroy] END


I have checked the paths in the environment options and they are correct.
Also when I select "Build Lazarus" from the tools menu nothing happens. :?

This is very frustrating because lazarus looks great.

Thanks again for your help jesusr

Anonymous

  • Guest
How can I connect a Database to Datasource1 ?
« Reply #12 on: June 20, 2004, 01:52:41 am »
So it's compiling components, great it means that you have a working fpc compiler, the problem is that lazarus is not finding the needed make file utilites. Check one of the replied messages the remark about the PATH environment variable:
"
Check your Environment Path variable, it should include the directory to the gnu compiling tools: make, as, ar, etc.
I use the following:
Set PATH=c:\pp19\bin\win32;C:\pp\bin\win32
in the pp19\bin\win32 I have the compiler and in pp\bin\win32 all the tools needed.
"
Only when I set the PATH="" I was able to reproduce what you describe what happen when clicking the "yes" button (ie nothing), so the problem well might be there.

Can you type the following in the msdos box from where you lauch lazarus

c:\ set > env.txt

and send the env.txt?

if you want you can send to me to my email address: jesusrmx <at> yahoo.com.mx

Anonymous

  • Guest
How can I connect a Database to Datasource1 ?
« Reply #13 on: June 22, 2004, 10:49:31 am »
Do I enter this in an *.ini file somewhere as well as setting it from the environment options menu?
I have tried setting the path at the dos prompt before loading laz.exe but then what happens is the compiler does launch when I click "Yes" to install, but then fails complaining that it can't find one of the units (interfaces).
Everything is installed in the default installation directories so the compiler and all the tools are in c:\lazarus\pp\bin\win32.

jesusr

  • Sr. Member
  • ****
  • Posts: 484
How can I connect a Database to Datasource1 ?
« Reply #14 on: June 24, 2004, 08:07:45 am »
Quote from: "Anonymous"
Do I enter this in an *.ini file somewhere as well as setting it from the environment options menu?
I have tried setting the path at the dos prompt before loading laz.exe but then what happens is the compiler does launch when I click "Yes" to install, but then fails complaining that it can't find one of the units (interfaces).
Everything is installed in the default installation directories so the compiler and all the tools are in c:\lazarus\pp\bin\win32.


No. Normally, fpc reads unit paths from fpc.cfg. Lazarus, when compiling components automatically creates an additional configure file: idemake.cfg in the lazarus folder with information from your installment and compiled components.

althought I never did anything different to the described above myself, there had been reports that the following command helped:

make ide OPT="@idemake.cfg"

but I dont know if it is helpful in your current situation about the interface unit problem.

This interface unit problem has been reported before doing a forum search could help, but there are also other resources as the mailing list (http://www.lazarus.freepascal.org/modules.php?op=modload&name=StaticPage&file=index&sURL=maill ), the bug tracker system (http://www.lazarus.freepascal.org/modules.php?op=modload&name=BugTracker&file=index), the lazarus ccr site (http://lazarus-ccr.sourceforge.net/index.php?wiki=LazarusDocumentation).

sorry for not being so helpful.

 

TinyPortal © 2005-2018