Suggested additions to SQLdb Tutorial 1 lazarus / 16-Databases ---------------------------------------------------------------------- Foxy · 2012-12-15 21:26 fpc 2.6.0 laz 1.0.2 firebird 2.51 ‘embedded’. WinXP Pro SP3, Windows 7 (32bit) (VMWare Fusion hosted on MAC OSX Lion 10.7.5 Mac Pro) Hi All, First my sincere thanks to Big Chimp for his excellent work on the SQLdb Tutorials.  As a newbie to fps/laz/firebird etc (Delphi/MSSQLServer for 15 years), I am finding them most useful. I suggest some minor amendments and some extra information which might serve as a guide (perhaps a 'newbie's getting started with SQLdb') to others venturing into this area.  Some of these additions relate to Firebird's latest 2.51 'Embedded' installation and its simplified, but poorly documented, issues of 'DLL and MSVC hell', others relate more directly to the instructions given in SQLdb Tutorial1. I make no apologies for 'cross posting' firebird installation guidance since I am a great believer in being able to find related stuff in the same place! So here goes ... FireBird 'embedded' on WinXP pro SP3 and Windows 7 The following strategy should result in a successful SQLdb development environment where FireBird 'embedded' Server can access a database placed elsewhere on the local system and Firebird Clients ( FlameRobin, LazDataDesktop and, of course, your own Client Apps ) can access the Server from anywhere in the Local system.  Multiple Clients can run simultaneously but Database Tables may not be editable from more than one Client at a time. 1.  Download and Install Firebird to a separate folder on a physical hard drive of      your system. 2. Using a text editor open and edit the firebird.conf file and edit the     RootDirectory = .  Also, it may be prudent to     Restrict database access to one or a small number of locations on your     Harddrive by using the DatabaseAccess = Restrict ;[;..]     Directive.       Tip Do not forget to remove the # (comment) at the start of this line!.       Then, save and exit the file. 3.  Create a sub-folder in this root eg 'FireBird_Client_Files' and copy the 5 .dll       files plus Aliases.cnf and firebird.msg (exclude the manifest and msvc files) from      the root into your newly created   sub-folder.             Rename the fbembed.dll file as 'fbclient.dll'  only in this sub- folder.  The        contents of this sub-folder will be copied to other places as described later. 4.   Create a sub-folder to store your firebird database(s) eg C:\db.  Leave FireBird              alone for now until we have  a Database Manager available ( FlameRobin and/or Laz DataDeskTop ) Installing latest FlameRobin ( 0.9.2.1851 Unicode ) Database manager ( if required ), registering a Server and creating a new ( empty ) DataBase. 1.  Download and Install FlameRobin into its default (ProgramFiles) root.      NB FlameRobin is compiled with a DIFFERENT(v71) msvc version than FireBird (v80).      Do not mix them up with  those in the Firebird Client Files’ Folder!! 2.  Copy all the contents of the 'FireBird_Client_Files' sub-folder you made earlier,      into the FlameRobin Root folder.       This will ensure that that FlameRobin becomes a Client to the Firebird Server. 3.  Start FlameRobin (should be no errors regarding DLLs!) and from the Server      menu select 'Register New Server'.          Enter your own preferred Display Name of the new Server You are registering      eg 'FireBird Embedded'.          NB Do not enter details for HostName and Port.  Firebird Embedded does NOT      support TCPIP connections / LocalHosts. 4.  Select your newly created Server and, from the DataBase Menu, select      'Create  New DataBase' . Enter your preferred Display Name for the DataBase eg 'TESTDB'. 5.  In the Database path box, enter the Full Path, FileName and extension of the      new Database  e.g. 'C:\db\TESTDB.fdb' . NB not just the path as implied by the       caption !! 6.  Enter your own preferred User Name and Password (dangerous to use      defaults). Then, Click the 'Create' button. 7.  After a couple of seconds you should see the DataBase appear in the new      server's tree. The newly created Database is now ready for use.  If you click on      its name you should see a list of objects in the tree.       If you right-click on 'Tables' and select 'Create New' (the only option available yet),      you will see a table create template for you to add column definitions, indexes,      constraints etc to create your first table. Installing Lazarus DataDesktop ( if required )  1.  Probably best to close FlameRobin for now. 2.  Open Lazarus and open the project 'lazdatadesktop' from the      lazarus\tools\lazdesktop folder. 3.  Compile and then Run the project, then copy the executable to a new folder      eg  'C:\Laz_DataDesktop'. 4.  To make it a client of the FireBird embedded Server, copy all the files from the      'FireBird_Client_Files' folder you made earlier.           NB. The executable will not run in the original folder it was compiled into       without adding the FireBird Client Files into the Output folder - not a good       idea. Best to copy the .exe, add the Client Files to a new folder, create a       shortcut and then its available at all times from the desktop. Installing your own FireBird Client Applications 1.  Try guessing this step!. OK you've got it.  For each separate SQLdb/FireBird      Application Project make sure the contents of the 'FireBird_Client_Files' folder      are copied into the folder where the compiled application will run.          TIP The SQLdb Tutorial1 omits to mention that, in order to open a connection      at design time, a copy of those Client files should be also in the lazarus.exe      root.  pdf version of this post attached. That's it. Please enjoy! Martin Fox ---------------------------------------------------------------------- BigChimp · 2012-12-16 07:54 Hi Martin, Thanks for your thoughtful and precise post. Looks like you know what you're doing. The wiki is free to edit and you certainly seem to have the necessary experience, motivation etc. It's good to have more people involved (TBH, I'm a bit tired of messing with these tutorials) -  I'd be more than happy if you updated the tutorial. That said, I hope you don't mind a bit of a blunt reply showing my perspective on your proposals - everybody's got their own way of working and preferences (i.e. your "find everything in one place" does make sense, but might not be appropriate once the number of db server/complexity of possible install scenarios starts to rise). Let me tell you first that I would welcome* separating out the setup instructions in the first tutorial into a separate article, because it is applicable to all sqldb tutorials and because the setup phase is taking a lot of space - and will take more if you increase the detail level of the instructions, e.g. as you propose below. *) ... and actually intended to... in the long run. 1. The FB dll handling in the tutorial should be improved, I agree with you. However, placing the dlls in one spot and your dbs in a subfolder IMO defeats the embedded concept a bit. Your databases are in another directory tree from your application etc. See 2. 2. My preferred solution for having one place for the fbembed/fbclient.dll and associated files: copy them once to the windows system directory so FlameRobin, Lazarus and your compiled programs can pick them up. You'd still need to copy the dlls when creating a setup of your application for deployment to clients of course... 3. On at least FPC 2.6.0 (Laz 1.0) and later: no need to rename fbembed to fbclient... though it is needed for older FPCs (and probably FlameRobin - especially if 2) is used). I'm thinking this rename step can be removed now (IIRC, it's still in the tutorial) 4. Restricting access using firebird.conf with an embedded db doesn't make much sense as the application will control what gets accessed anyway - and that is controlled by the local user (and his OS level pemissions - fbembed.dll runs in the user application process - ie. under his credentials). A bit like protecting against hacking your own computer? Different from a server where remote clients may try to obtain unauthorized access to other files... 5. Flamerobin section: could be nice, as it is a useful tool, but I'd perhaps prefer to have such info in either the Firebird in action wiki article, a Firebird embedded wiki article (IIRC it's there) or the separate db tutorial setup article mentioned earlier. 6. "User Name and Password (dangerous to use defaults)" No it's not: for the embedded server it doesn't matter security-wise except AFAIR you need to specify an existing username. SYSDBA will do. Client/server is a different story. 7. "Compile and then Run the project, then copy the executable to a new folder eg  'C:\Laz_DataDesktop'." Easier would be IMO to not copy but add a menu entry/shortcut lazdatadesktop to the Lazarus tools (external tools) menu. This way you keep the code in 1 spot with the exe - better if you update Laz, recompile lazdatadesktop Thanks, BigChimp ---------------------------------------------------------------------- Foxy · 2012-12-16 12:18 Hi Big Chimp Thanks for your swift response. I have no experience in Wiki editing or indeed forum posting. I started by installing FPC/LAZ 3 weeks or so ago, and bought the book! I found your Tutorial1 on the wiki and decided to play with SQLdb. At that stage I had no Firebird, FlameRobin or LazDataDesktop so I needed to address these requirements before starting with the tutorial.  It took longer to install these features and get them running than it did to write my post, so I decided to write down my experiences in the hope I could save others some time. I shall wait a while to see if others are at all interested before changing anything anywhere. However, I have a couple of comments arising from your post. 2.  This is not recommended by Firebird since it is contributing to the 'DLL HELL' problem.  Particularly with the      MSVC libs which should be considered as 'Private' rather than 'Shared' libraries especially because they are      'old libraries' only necessary because Firebird are using them for their project.       How many hours have you had to spend digging out long forgotten dlls from System32 on one machine when      you are transferring your development environment to a new machine and discover nothing works anymore?      BTW, as my post pointed out, FlameRobins MSVC lib is different again so we would end up with 3 sets of libs in      System 32 (2 old and the latest that came with the machine). 4.  Agreed, but no harm in building good habits.  Sooner or later experience gained with embedded will result      hopefully, in applications designed to run in the big bad world on servers and clients beyond our control. 6. Same response as above 7.  Good idea, thanks  Again thanks ---------------------------------------------------------------------- BigChimp · 2012-12-16 12:52 Let's agree to disagree on the security & DLL stuff - I've finished copying fbembed.dll around everywhere on my dev machine and I think it's a logical step to take (on a dev machine) Hope you'll be able to spruce up those tutorials!