Recent

Author Topic: Need SQL Help  (Read 2414 times)

greertr

  • Full Member
  • ***
  • Posts: 113
    • Virtual Pilot Dashboard
Need SQL Help
« on: January 11, 2017, 11:34:16 pm »
This unit continues to give me sql errors...I'm weak on sql, so I decided to post the entire unit code and see if someone is willing to help me get it going.

Right now I can't check the ZConnection Connected or ZQuery Active checkboxes in the Object Inspector, so I tried putting them into the form.create - still getting sql errors but can't open the database.

any help would be appreciated...

EDIT:  Got it resolved - found the bug - shot in the ole' foot - I had renamed the folder containing the db but neglected to update the data base path in the object inspector  :-[
« Last Edit: January 12, 2017, 01:24:59 am by greertr »

mangakissa

  • Hero Member
  • *****
  • Posts: 1131
Re: Need SQL Help
« Reply #1 on: January 12, 2017, 09:11:55 am »
This has nothing to do with weak on SQL, but designing.

This is what I do:
  • Create a 'global' datamodule.
  • Put component Zconnection on it
  • Fill in the required properties
  • Check your connection to the database (if it works @designtime, it also works @runtime
  • Go to the project options --> forms
  • Make sure the datamodule will created before you mainform
    In auto-createforms should be filled like this:
    datamodule1
    form1
  • close the project options form
Now you can do two things:
  • Open your database in de Oncreate of the datamodule
  • Open your database in de FormCreate of your mainform.
    This works now, because the datamodule and its components are already loaded in memory and can be accessed.
    don't forget to put the datamodule in the uses.
It's you choice, but in this way the connection always works (if the database is found).
Lazarus 2.06 (64b) / FPC 3.0.4 / Windows 10
stucked on Delphi 10.3.1

greertr

  • Full Member
  • ***
  • Posts: 113
    • Virtual Pilot Dashboard
Re: Need SQL Help
« Reply #2 on: January 12, 2017, 12:04:22 pm »
Thx again Manga!

 

TinyPortal © 2005-2018