Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. Romanian
  4. Problema cu legarea la baza de date
QtWS25 Last Chance

Problema cu legarea la baza de date

Scheduled Pinned Locked Moved Romanian
1 Posts 1 Posters 2.9k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    lzr_mihnea
    wrote on 27 Mar 2013, 10:25 last edited by
    #1

    Am introdus codul urmator
    @#include <QCoreApplication>
    #include <QtSql>
    #include <QtDebug>

    int main(int argc, char *argv[])
    {
    QCoreApplication a(argc, argv);

    // QString servername = "LOCALHOST\SQLEXPRESS";
    QString servername = "LOCALHOST\MYSQL";
    QString dbname = "test.dat";

    QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
    
    db.setConnectOptions();
    
    QString dsn = QString("DRIVER=(SQL Native Client);SERVER=%1;DATABASE=%2;UID=root;PWD=root;").arg(servername).arg(dbname);
    

    // QString dsn = QString("DRIVER=(SQL Native Client);SERVER=%1;DATABASE=%2;Trusted_Connection=Yes;").arg(servername).arg(dbname);

    // db.setDatabaseName(":memory:");
    db.setDatabaseName(dsn);

    if(db.open())
    {
        qDebug() << "Opened!";
        db.close();
    } else {
        qDebug() << "Error: " << db.lastError().text() ;
    }
    
    
    return a.exec(&#41;;
    

    }
    @

    Si obtin eroarea "out of memory Error opening database"
    Problema pare a fi la numele serverului sau string-ul dsn.
    Mentionez ca folosesc UniServer, cu Apache si MySQL.

    Salutare,
    Mihnea

    Edit: Rezolvat! [ https://qt-project.org/forums/viewthread/26150/#119424 ]

    1 Reply Last reply
    0

    1/1

    27 Mar 2013, 10:25

    • Login

    • Login or register to search.
    1 out of 1
    • First post
      1/1
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved