Important: Please read the Qt Code of Conduct -

Microsoft sql db access gives error in opening..

  • Hi,
    I wrote a program to access Microsoft sql database. It works fine in desktop. But when I run same program in android device I'm getting error:
    bq. 04-09 06:17:41.784: W/Qt(1240): kernel\qsqlquery.cpp:368 (bool QSqlQuery::exec(const QString&)): QSqlQuery::exec: database not open

    Here is my code:

    @ QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
    db.setDatabaseName("Driver={SQL Server};Server=;Database=sms_exp;");
    qDebug ("Error");
    qDebug ("OK");

    QSqlQuery query (db);
    query.exec("SELECT item_code, item_des FROM prod_mast WHERE item_code = 0100000210");
    while (
            QString name1 = query.value(0).toString();
            QString name2 = query.value(1).toString();
            qDebug (qPrintable(name1));
            qDebug (qPrintable(name2));

  • Lifetime Qt Champion


    AFAIK there's no ODBC c++ client library for android (I could be wrong and be happy to be proven so).

    If you have one you need to build the plugin

Log in to reply