开发者

Sqlite3 network oddity

I have a simple QT program to read an sqlite3 database. Annoyingly, my program failed when the actual database is on the network as a mapped drive (Windows 7) but works when the database is on the local drive. The code I'm using is below and just for experimental purposes.

    QFileInfo fileInfo(m_lastDatabaseFile);
    QString host = fileInfo.canonicalPath();
    QString filename = fileInfo.fileName();
    m_dataBase = QSqlDatabase::addDatabase("QSQLITE");
    m_dataBase.setHostName(host);
    m_dataBase.setDatabaseName(filename);
    qDebug() << " valid: " << m_dataBase.isValid(); 
    if (m_dataBase.open() )
    {
        QStringList tableList = m_dataBase.tables(QSql::Tables);
        qDebug() << "Database open.";
        QSqlQuery query = m_dataBase.exec("SELECT * FROM PallolBoards");

        qDebug() << "Found: " << query.size();
        if (q开发者_如何学Gouery.size() <= 0)
        {

            QSqlError err = query.lastError();
            qDebug() << "Last error: " << err.text();

        }
        while (query.next() )
        {
            QString title = query.value(0).toString();
            qDebug() << "Query: " << title;
        }
    }
    else
    {
        QMessageBox::critical(this,"Invalid database",m_dataBase.lastError().text());
    }

Any clues anyone? So H: will fail but D: succeeds.


At least in windows vista there was a security setting controlling if an application was allowed to access network shares or not.

There is also a dependency between Internet security settings(accessible through e.g. internet explorer) and access to network shares.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜