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=192.168.1.3;Database=sms_exp;");
    db.setUserName("sa");
    db.setPassword("xxxxxyy");
    if(!db.open())
    {
    qDebug ("Error");
    }
    else
    {
    qDebug ("OK");
    }

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

  • Lifetime Qt Champion

    Hi,

    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
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.