×

Discussion Board

Results 1 to 2 of 2

Thread: help~help~

  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    1

    Question help~help~

    How can I write a database searching program with an existing .db file.
    It looks like the .db file can't be read.
    What's more,the .db file can't be added into the built .sis file.
    The .sis file only 25KB,but the .db is 1.5MB.
    I'm a newbie ,please help me ~~Thank you


    database.h:
    Code:
    #ifndef DATABASE_H
    #define DATABASE_H
    #include <QSqlDatabase>
    #include <QSqlQuery>
    static bool createConnection()
    {
        QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
        db.setDatabaseName("\:P4.mdb");
        if(!db.open()) return false;
        QSqlQuery query;
        return true;
    }
    #endif // DATABASE_H


    I've written this code in mainwindow.cpp
    Code:
            QSqlQueryModel *model = new QSqlQueryModel;
            model->setQuery("select * from UAA1");
            model->setHeaderData(0, Qt::Horizontal, tr("Point"));
            model->setHeaderData(1, Qt::Horizontal, tr("Desr"));
            model->setHeaderData(2, Qt::Horizontal, tr("PID"));
            model->setHeaderData(3, Qt::Horizontal, tr("Sensor"));
            model->setHeaderData(4, Qt::Horizontal, tr("Drwg"));
            model->setHeaderData(5, Qt::Horizontal, tr("Drwg2"));
            model->setHeaderData(6, Qt::Horizontal, tr("Timer"));
            model->setHeaderData(7, Qt::Horizontal, tr("ExpectValue"));
            model->setHeaderData(8, Qt::Horizontal, tr("RealValue"));
            ui->tableView->setModel(model);
            ui->tableView->show();

    I just want to make a program to seaching the data from a table.
    Or anyone tell me a easier way.
    Thanks.
    Last edited by officer0310; 2011-03-24 at 13:12.

  2. #2
    Registered User
    Join Date
    May 2009
    Location
    Guatemala
    Posts
    186

    Re: help~help~

    First, the question title won't help. I seriously recommend choosing a better title next time.

    As for your question, to include the database in the sis package, you have to add something in the project (pro) file.

    Something like this (assumming the database is in the same path as the source):

    Code:
    database.sources = "your_database"
    database.path = .
    DEPLOYMENT += database
    -CarlosDL

Similar Threads

  1. Help! Help! Ovi map locationg no N900 is mass!!!!
    By andrew@sh in forum Nokia N9
    Replies: 1
    Last Post: 2010-12-15, 09:47
  2. bluetooth passkey, i need help , pls help me , thank u
    By yuhh in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2009-05-18, 10:25
  3. IrDA printing.. Help help help
    By Jazsh in forum General Development Questions
    Replies: 5
    Last Post: 2006-04-05, 19:13
  4. Help: Developer needs help for quick Beta Testing
    By papaddy in forum Mobile Java General
    Replies: 2
    Last Post: 2004-09-13, 08:57
  5. Help! Help! My IP address is changing like crazy !!
    By jwynn_in_nh in forum Mobile Java General
    Replies: 0
    Last Post: 2003-07-22, 22:10

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •