Page 1 of 1

How to connect to a firebird database

Posted: Sat Jan 29, 2011 11:36 pm
by tseyfarth
Hello all,

My first time using ODBC, connection strings etc. I was able to get connected and work with a PostgreSQL database just fine, but cannot seem to get even a connection to a Firebird database. The ODBC drivers are installed, the Firebird tools connect etc, but after spending several hours trying within PB, cannot seem to do it. Can anyone help with some sample code?

This is what I have tried, nothing worked :(

Code: Select all

If DB = 1 ;FB
    
    DbID = UseODBCDatabase()
    river="Firebird/InterBase(r) driver,Uid=SYSDBA,Pwd=masterkey,Dbname=C:\AxcysV10\Firebird\Data\axcys.fdb"
    
    
    
    ;Driver=Firebird/InterBase(r) driver;Uid=SYSDBA;Pwd=masterkey; Dbname=C:\AxcysV10\Firebird\Data\axcys.fdb
    ;Driver="{Firebird/InterBase(r) driver};Uid=SYSDBA;Pwd=masterkey; Dbname=C:\AxcysV10\Firebird\Data\axcys.fdb"
    
    ;Result = OpenDatabase(#Database, DatabaseName$, User$, Password$ [, Plugin]) 

    
   
   ; DbID=OpenDatabase(#PB_Database_ODBC, "Driver=Firebird/InterBase(r) driver,Dbname=C:\AxcysV10\Firebird\Data\AXCYS.FDB,CHARSET=NONE","SYSDBA","masterkey")
    ;DbID = OpenDatabase(1,"host=localhost port=3050 dbname=C:\AxcysV10\Firebird\Data\axcys.fdb","SYSDBA","masterkey",#PB_Database_ODBC)
   ; DbID = OpenDatabase(1,"host=localhost port=3050 dbname=C:\AxcysV10\Firebird\Data\axcys.fdb","SYSDBA","masterkey",#PB_Database_ODBC)
    DbID = OpenDatabase(#PB_Any,"host=localhost port=3050 dbname=C:\AxcysV10\Firebird\Data\axcys.fdb","SYSDBA","masterkey",#PB_Database_ODBC)
     
  EndIf


Errors = DatabaseError()
On each attempt the microsoft ODBC object errors. I think part of my problem is plain confusion on how to handle the connection string. The one I found on the net, as a result of a previous post, has semi colons in it so obviously it cannot be used, "as is" from within PB since PB interprets the semis as remarks, this is why I added quotes to the line. But even with that, I am just blind to where and how to use this string.

Code: Select all

Driver="Firebird/InterBase(r) driver,Uid=SYSDBA,Pwd=masterkey,Dbname=C:\AxcysV10\Firebird\Data\axcys.fdb"
The docs and sample does not help me either, particularly since the parameters do not appear to be the same.

If anyone can provide some sample code, I would be very grateful!

Thank you!
Tim

Re: How to connect to a firebird database

Posted: Sun Jan 30, 2011 6:30 am
by IdeasVacuum
has semi colons in it so obviously it cannot be used
Well, let's see that string - if that is what the db requires, then that is what you have to work with.

Re: How to connect to a firebird database

Posted: Sun Jan 30, 2011 7:09 am
by Paul
PureBasic's OpenDatabase command assumes the ODBC source has already been set up.
You either need to set up manually through Admin Tools/Data Sources or through code which is where your special connection string comes in.
You need to use API for that so do a search on the forum for "SQLConfigDataSource"
There has been plenty of procedures posted which show how to connect to Access, MySQL, Oracle, etc. using "SQLConfigDataSource"

Re: How to connect to a firebird database

Posted: Mon Jan 31, 2011 1:23 am
by tseyfarth
Thank you for your responses.
Will search and work with your suggestions!

Tim