#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    9
    Rep Power
    0

    Connecting a Firebird database to C#


    Hello everybody,

    I have never worked with Firebird databases before. I downloaded Firebird 2.1, but it doesn't seem to work? If I double click fbserver.exe, nothing happens. Also if I try to open a .gdb-file with fbserver (the file is pulled from a Firebird program) nothing happens. What am I doing wrong?
    I want to connect this file to a Visual C# application.
    I first tried to connect it using ODBC but I wasn't sure if that was possible.
    Now I downloaded Firebird ODBC, but I can't add the OdbcFb.dll to the reference. I receive an error saying that the file is probably not accessible or not a valid assembly or COM component. Can anybody help me with this problem?
    Thanks in advance!
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    9
    Rep Power
    0
    Have you "installed" firebird? If so then Firebird is probably already running as a service, if not then what you have done by double clicking it is to start it as an application - but what did you expect to happen?

    A server is a program that when fed with data (often a question) it converts the data or retrieves data and returns it. Apache is an HTTP server. If you ask it an http question it will respond with an http file. Similarly if you ask Firbird an sql question it will respond with a data set, but database servers are multi-purpose and multi-tasking, therefore before you can ask a question you have to establish the context of the question, ie you have to tell the database server what database you want data from.

    Not only this but firebird, like (most) other database servers, can be accessed from different programming environments. Firebird can be accessed from php, C++, C#, Delphi and probably many other programming languages. The Firebird server itself can understand only one language and to resolve this each programming language has its own .dll which acts as an interpreter between the programming language and the database server language. You site the ODBC interface which is just one example of this. (I believe Firebird is supplied with a number of such interfaces)

    So assuming you have installed Firebird correctly and it is running as a service, what you need next is the correct .dll for your programming language, and to get you started you can use the command line program ISQL that comes with Firebird or you may prefer a GUI tool like FlameRobin.

    While I totally disagree with some of the qualitative comments made in this article (because I think they are biased, but then so am I) you might like to work through this link: (Link blocked by forum) ** and I am sure there are others you could find.

    **I'm not sure why this forum rule exists but try googleing "using firebird with c#" and look for "Beginner's Tutorial on Using the Firebird ADO.NET Client 2.5 ..."
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    9
    Rep Power
    0
    Thanks,
    Haha biased is an understatement, they sound like salesmen.
    I thought there would be an exe to show the content of the database, but it just the server then.
    Now I try to connect to my database using both ISQL and my C# application with the default user name and passwrd, but I receive an error: 'Your user name and password are not defined. Ask your database administrator to set up a Firebird login.' Clear, but I receive the same message trying to create a database. Strange...
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    9
    Rep Power
    0
    Nevermind my last reply. I have a new problem.
    I got the right user name and password, and now I receive the message: "is not a valid database". Both in ISQL (with SQLCODE = -922) and C# (Exception 0x80004005). Is it possible to open *.gdb files in Firebird? Could it be a problem that the database is created on a 32-bit and I'm working on a 64-bit?
    Thanks!
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    9
    Rep Power
    0
    .dgb is the old extension for an Interbase/Firebird database, but there may be many reasons why you are not connecting.

    I'm afraid I'm off to work now but will give you examples and a program to read them tonight.

    Geoff
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    9
    Rep Power
    0
    Hi Geoff,

    I downloaded a DatabaseConverttool, which also indicated that it's not a valid database. But it gave a tip to try the 32 bit version of Firebird 2.1. And it works.
    Now I'll try to read it into my application. If you have an example of that, that would be helpfull.
    Thanks for your help!
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    9
    Rep Power
    0
    I'm afraid I don't have any examples of c# code since I only program in Delphi (and just starting in php) but I have put my Manager program on the internet if you care to download it. From it you can inspect the file structure and contents of Firebird databases. The address is RAD-Software dot com forward slash Manager dot html
    It's not as powerful as some, but it has done me well over the past 10 yrs.

    Please let me know how you get on.

    Good Luck
    Geoff
  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    9
    Rep Power
    0
    Okay, thanks for your help!
    Do you know if it is possible to search through a connected database? I mean, if I have to get all contents to a List or an Array first, my application will probably take more then ten minutes to load. So I only want to bring important and usefull values to variables in my application.
  16. #9
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    9
    Rep Power
    0
    You cant load a database (a collection of tables) into an array, so I assume you are talking about a table. the answer is to use the Where clause of the SLQ statement.

    Geoff
  18. #10
  19. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    9
    Rep Power
    0
    Great!

IMN logo majestic logo threadwatch logo seochat tools logo