0

I have local database, that I want to connect with. Here is my code, but unfortunately it doesn't work.

    QString servername = "SYSDBA@localhost";
    QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
    db.setHostName(servername);     
    db.setDatabaseName("Driver={InterBase ODBC driver};DATABASE=D:\\baza\\BAZA.fdb;");      
    db.setUserName("SYSDBA");
    db.setPassword("masterkey");
    if (db.open())
        qDebug() << "Connected";
    else
        qDebug() << "Nope :(";  

I would appreciate any help.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
karollo
  • 573
  • 8
  • 22
  • _"it doesn't work"_ Can you be more specific? Do you get an error, what happens? Which driver are you using? As "InterBase ODBC driver" suggests you are not using the Firebird ODBC driver, but instead one for InterBase. – Mark Rotteveel Dec 06 '17 at 18:55
  • I can't connect to database. You are right, "InterBase ODBC driver" syntax is wrong. Is this only mistake there is in my code? Greets – karollo Dec 06 '17 at 19:07
  • I'm not familiar with QT, and my experience with ODBC is very limited. Consider posting to the firebird-odbc mailinglist or checking the [documentation of the Firebird ODBC driver](https://www.firebirdsql.org/file/documentation/reference_manuals/driver_manuals/odbc/html/fbodbc205.html) – Mark Rotteveel Dec 06 '17 at 19:09
  • u use C++? then perhaps IBPP library would help better – Arioch 'The Dec 07 '17 at 08:22

1 Answers1

1

I finally got it. You have to set up your ODBC driver in windows: https://kb.brainwaregroup.com/operationsmanager/faces/kb/brainwaregroup%20kb/article/AA-00486

Then you can connect it directly using dsn configured in windows administrative tools:

QString servername = "localhost";
QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
db.setHostName(servername);
db.setDatabaseName("YOUR_DSN_NAME");
db.setUserName("SYSDBA");
db.setPassword("masterkey");
eyllanesc
  • 235,170
  • 19
  • 170
  • 241
karollo
  • 573
  • 8
  • 22