Recent

Author Topic: Firebird embedded dynamic connect.  (Read 5183 times)

markhorrocks

  • New member
  • *
  • Posts: 8
Firebird embedded dynamic connect.
« on: April 12, 2012, 05:15:15 am »
I am trying to set SQLQuery1.DatabaseName := ExtractFilePath(ParamString(0) + 'mydb.fdb' in the form create or show events and I get an file open error that its still looking for the design time file.

How can I set a db path name based on the current install path dynamically. This works fine if I leave the path set in design time. Problem with that is that I don't know whether program files will be (x64) or not.

This works fine in Delphi using Firebird server but i want to use embedded.


goldenfox

  • New Member
  • *
  • Posts: 47
Re: Firebird embedded dynamic connect.
« Reply #1 on: April 12, 2012, 07:08:06 am »
Maybe set it like this?

Code: [Select]
SQLQuery1.Database := IBConnection1;
IBConnection1.Databasename := /path/to/mydb.fdb


 

markhorrocks

  • New member
  • *
  • Posts: 8
Re: Firebird embedded dynamic connect.
« Reply #2 on: April 12, 2012, 09:06:33 am »
Maybe set it like this?

Code: [Select]
SQLQuery1.Database := IBConnection1;
IBConnection1.Databasename := /path/to/mydb.fdb

Now I see that it has nothing to do with setting the DatabaseName in code. Now, I get the same error at runtime even when i leave it set at design time where it can connect.
« Last Edit: April 12, 2012, 09:12:55 am by markhorrocks »

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Firebird embedded dynamic connect.
« Reply #3 on: April 12, 2012, 10:07:33 am »
Strange.

Storing your database in program files is not a smart move, security wise (unless it's a read only db, I suppose). See the wiki articles on cross platform programming and windows for some ideas on where to store data files.
You might be having permission problems (access denied) - but then it's strange it works at design time and not at run time.

Edit: oh, if it works at design time, not at run time: please make sure the firebird embedded dlls are present in the application directory (or windows\system32 directory, I suppose, but I wouldn't go that route).

Hint: posting your Lazarus version, platform (obviously some form of Windows) and actual code is not a bad idea when posting...
« Last Edit: April 12, 2012, 10:09:06 am by BigChimp »
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

markhorrocks

  • New member
  • *
  • Posts: 8
Re: Firebird embedded dynamic connect.
« Reply #4 on: April 12, 2012, 01:05:19 pm »
I think I have this figured out. The sigsegvs seem to be due to having a separate IBconnection component in each form. When I refactored that to having a single IBconnection in the main form the issue seemed to be resolved. In Delphi I used a single database in a separate RDM app.

The connection errors were a problem to me because I had the server running at the same time as trying to make the app work with embedded. I gave up embedded and stuck to the server and everything seems ok now.

markhorrocks

  • New member
  • *
  • Posts: 8
Re: Firebird embedded dynamic connect.
« Reply #5 on: April 12, 2012, 01:12:14 pm »
Storing your database in program files is not a smart move, security wise (unless it's a read only db, I suppose). See the wiki articles on cross platform programming and windows for some ideas on where to store data files.
My first bright ideas was just to install the lot in c:\myapp but whatever antivurus or something installed on the clients computer complained that myapp might be malware. I guess because it wants to install into the root directory.

Hint: posting your Lazarus version, platform (obviously some form of Windows) and actual code is not a bad idea when posting...
I was getting round to making up a demo but then the eureka moment hit me. Its windows running in a vbox vm. I normally operate in ubuntu. This is the only GUI app I'll probably ever do :-)

markhorrocks

  • New member
  • *
  • Posts: 8
Re: Firebird embedded dynamic connect.
« Reply #6 on: April 13, 2012, 05:10:20 pm »
I still can't get this to work. No matter where I try to set my database name in code, I still get an error saying it can't find the design time path.

 

TinyPortal © 2005-2018