Jump to content

Trying to access Firebird database

Recommended Posts


I'm trying to connect to Firebird database via AutoIt. Something that was supposed to be a cakewalk so far ended with no succes, as usual hoping for your help.

I'm using the following Firebird Direct Access for Visual Basic DLL: http://sourceforge.net/projects/fbdll4vb/files/. And the code below comes from Stephen Podhajecki (Eltorro) Firebird UDF (only parts I need at the moment):

Global $fb_dll = DllOpen ("fbdll4vb20.dll")

Firebird_ConnectDatabase ("C:\Program Files\AIT\Projetex 9\Projetex Server\Database\Projetex.fdb", "ODCB", "123")
If @error Then MsgBox (48, "Error", "Failed to login!" & @CRLF & "Error code: " & @error)
Firebird_DisconnectDatabase ()

Func Firebird_ConnectDatabase ($p_database, $p_username, $p_password)
  Local $connect_str = "char[%d];char[%d];char[%d]"

  $connect_str = StringFormat ($connect_str, StringLen ($p_database) + 1, StringLen ($p_username) + 1, StringLen ($p_password) + 1)

  Local $fb_struct = DllStructCreate ($connect_str)
  DllStructSetData ($fb_struct, 1, $p_database)
  DllStructSetData ($fb_struct, 2, $p_username)
  DllStructSetData ($fb_struct, 3, $p_password)

  Local $return = DllCall ($fb_dll, "int", "ConnectDatabase", _
                           "ptr", DllStructGetPtr ($fb_struct, 1), _
                           "ptr", DllStructGetPtr ($fb_struct, 2), _
                           "ptr", DllStructGetPtr ($fb_struct, 3))

  $fb_struct = 0

  Return SetError ($return[0] <> 0, 0, $return[0])

Func Firebird_DisconnectDatabase ()
  Local $return = DllCall ($fb_dll, "int", "DisconnectDatabase")
  Return SetError ($return[0] <> 0, 0, $return[0])

The code above gives me this:


The specific kind of server\database I need to connect to is belong to following application if that matters: http://www.projetex.com/, it is using Firebird 2.5. While ODBC\123 comes from following settings in the Server Administrator utility:


I've installed a VM with above mentioned application, server and databse running on it so I have admin rights to access it for testing. Nevertheless when I tried to use a gsec (a command prompt utility that comes with the app) to display a list of users it only gave me this:

gsec -user Admin -password admin -database "C:\Program Files\AIT\Projetex 9\Projetex Server\Database\Projetex.fdb" -display
use gsec -? to get help
Your user name and password are not defined. Ask your database administrator to setp up a Firebird login.
unable to open database.

So I changed it to ODBC, and there was some progress:

gsec -user ODBC -password 123 -database "C:\Program Files\AIT\Projetex 9\Projetex Server\Database\Projetex.fdb" -display
invalid request BLR at offset 37
table USERS is not defined

I tried to add a user mjolnir\123 and this time there was no progress:

gsec -user ODBC -password 123 -database "C:\Program Files\AIT\Projetex 9\Projetex Server\Database\Projetex.fdb" -add mjolnir -pw 123
An error occured while attempting to add the user.
invalid request BLR at offset 51
table USERS is not defined

It seems I'm not quite understand how the damn thing works. The Server Administrator utility have plenty of users including the admin, all of the have access to read the database and could do this via Projetex client, neither cann't do this nor via gsec, not programmaticlly via AutoIt code above. And then it says smth about "table USERS" which is not defined apparently, looks like database users is not the same thing as server users and I'm doing it wrong.

Edited by mjolnirmarkiv
Link to post
Share on other sites

Are your %ProgramFiles% permissions restricted?

I have a system that needs to write to that folder and on some machines it can not.  You need Admin level access.

Try placing the .fdb in another folder? Or amend the Windows Security settings for that folder?  

Other RDBMS that store their database files in similar locations run into similar problems - also, while you are at it, check if McAfee is installed/blocking your access? Its notorious for blocking access to the %Temp% folder, which many db tools use to access files.


Why is the snake in the sky?

Link to post
Share on other sites
  • 7 months later...

I played with my Firebird db over the weekend.  Do you have FlameRobin (or similar?) installed?  Have you defined users?  

I would suggest first just running a few SQL query tests in FlameRobin to see if it actually works before trying to access it with AutoIt.


Why is the snake in the sky?

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By nooneclose
      Good morning, I am trying to figure out if it is possible to check if these invoice lines exist or not. 
      Here are the table and column name: INVOICELINE.INVOICELINENUM (a required field if created)
      Here is a picture of what I am talking about. (Do not worry about security. the picture is from a demo test site so all information is fake)
      is there any way to check if these fields exist or not? (they do not exist unless the user clicks on "New Row")
      Example: line 11 does not exist right now. How would I go about to see if it did or not? 
      This is what I have so far:
      SELECT DISTINCT iv.invoicenum, iv.description FROM invoice AS iv JOIN invoiceline AS ivl ON iv.invoicenum = ivl.invoicenum AND iv.siteid = ivl.siteid /* = 'nothing' and yet somehow not null? */ WHERE iv.invoicenum NOT IN (SELECT invoicelinenum FROM invoiceline WHERE invoicelinenum IS NOT NULL) I get 0 results where I should get more than 0. 
    • By TheSaint
      Only early days at this point, but I have been pondering such a program for a while.
      As good as calibre is (thank you Kovid Goyal), which is a great and wonderful ebook suite of tools and a fair database, it does have its limitations. One of which, is how it deals with multiple libraries, another is the views you get. CalibBrowser will seek to address those.
      What CalibBrowser is not going to be, is an editor for existing calibre libraries. That will be left up to calibre, which is very much needed still, and covers many aspects I will never look at. Unlike calibre, which is quite a complex program, CalibBrowser also seeks to be simple. It is mainly a viewer, at this point, but will later be able to create its own libraries. However, it does not and will not export them to calibre, especially as calibre employs a far different method and structure to what CalibBrowser will employ.
      When CalibBrowser starts, it looks for calibre executables and the main Calibre Library. Whatever isn't found, you get prompted for with a browse option.
      A calibre library, is a set of ebook folders (Author\Ebooks) and a database file, always named metadata.db, and which causes an issue when it comes to multiple libraries, but makes life a bit easier when reconstructing any corrupted libraries. However, there are better ways to deal with that, as my program will show.
      The metadata.db file is an SQL database, so I am having a learning curve right now, as I have only ever dealt with an SQL database previously, codewise, when I created my INItoSQL program some time last year, as an exercise to prove a point.
      At the moment, things are pretty basic, and not everything works 100%. Here is a screenshot, to give an idea of it, but keep in mind, I intend to expand the current GUI for other stuff I will be adding.

      Older Screenshots
      Gawd, I just noticed the '3|7' in the Book Input field (original screenshot). I was using that during troubleshooting for the multiple images scrolling and forgot to disable it ... not that it impacts anything. When it comes to maths, I struggle a bit, especially when tired. Right scrolling was easy, with a continuous loop, was easy to implement. Left scrolling was significantly harder for my poor brain ... until I realized I needed to see them as Min and Max.
      As you can see the program is usable, and all the buttons, aside from the Program Information one, work. You can even load different calibre libraries, and even reload after making changes to one with calibre. The calibre program does not need to be running, even to view an ebook in the Calibre Reader. The combo selector for a library and the ADD button are only temporarily placed where they are, until I expand the GUI.
      My intention at this point, is to add another five thumbnail images, directly below existing. Currently they aren't clickable, but I may add that.
      Here is another screenshot, of what you see when you click the larger Cover image.

      If you want to have a play with the program as is, then you will need to also get the 'sqlite3.dll' file from some online source. When CalibBrowser starts successfully with the selected calibre library, it copies its metadata.db file to a sub-folder of the program called 'Backups'. It also creates a sub-folder in that, based on the library name, to house it. That copied file, is the one the program uses, though it does not even edit that, and file modification is checked every time the program starts with a particular library, or when you Reload or select a library. If the original source file has been modified, then the program copy is overwritten. The Reload Database button does nothing, if there is no change detected, and reports such.
      Place the required 'sqlite3.dll' file in the CalibBrowser root folder. Download includes source files (sqlite3.dll excepted).
      Also required of course, is an install of calibre, plus some ebooks in a created library - Calibre Library is the default when you first add ebooks to calibre. The Mobile Read Forums, is a great source for all things ebook, and calibre can be found there in the E-Book Software section.
      CalibBrowser.zip  - Upload 4  (previous downloads: 1 + 12 + 5)
      CalibBrowser (new).zip
      My apologies for the program being created in AutoIt v3.3.0.0. It is the first one I have done in a while, with an older AutoIt version. Basically my Win 7 Netbook, which has a current version of AutoIt, was busy and is always busy doing something, and not suitable for doing big projects for several reasons. My older but more powerful Win XP Laptop, has a better programming environment, better computer chair (most important for my knees etc), better external monitor (wider and newish), full size external keyboard & mouse, and a great suite of setup tools to assist me. I run several older versions of AutoIt already on my Laptop, but haven't yet determined what I need to adjust to add a current version of AutoIt to the mix. This also applies to my hugely beneficial Toolbar For Any program (one of those tools), which I constantly use with SciTE. At some point, when finished, I may update the program to the current AutoIt version ... especially as I believe I am now proficient enough to do so, having become quite familiar with it in the last year or so, making many programs with it.
    • By Skeletor
      Hi All,
      Here's a really simple question. 
      I ran the code from the helpfile under: _SQLite_Open

      Issue is I end up with an error message: SQLite3.dll Can't be Loaded!
      I placed the *.dll in the include folder, but still nothing. 

      Where must this file be placed.
    • By RamDemon
      Did anyone tried to  use Redis  with AutoIT as store DB ?
       Redis <-- more about it
    • By Wingens
      I want to create a program/script wich uses a database to store it's data.
      Now I am puzzeled by wich database server/type I should use.
      Can you guys help me?
      The program/script I want to create is used for multiple computers, where the insert data en read/modify it afterwords.
      There is going to be adding files to a share and the links as data in de database.
  • Create New...