×

Discussion Board

Results 1 to 4 of 4

Thread: Qstring Query ?

  1. #1
    Regular Contributor
    Join Date
    Oct 2008
    Posts
    323

    Post Qstring Query ?

    Dear All,
    Code:
    QString Bufferval;
    //Bufferval - contains [ +12345 ]
    QString retval(query.exec(QString("select * from DataTable where Number = %1").arg(Bufferval)));
    in the retval i am not getting anything ? why ? what s wrong in the Query?

  2. #2
    Regular Contributor
    Join Date
    Oct 2008
    Posts
    323

    Post Re: Qstring Query ?

    Dear All,

    the below code is working fine in the emulator.
    but if i check in Device its not working

    problem coming on the Query.exec line?
    i am not able to find why its not working in the device?

    any one have idea about this?

    Code:
    Consider: 
    CountMatch - 5
    Match            - QList<int> Match
    
            for(int i =0; i<CountMatch; i++)
            	{
    				int Bufferval(Match.at(i));
    				query.exec(QString("select * from MTable where Number = '%1'").arg(Bufferval));
    				while (query.next()) 
    					{
    						MTable* Mitem = new MTable();
    						Mitem->Message       = query.value(2).toString();
    						MessageNumbers.append(Mitem);
    					}
            }

  3. #3
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: Qstring Query ?

    Most "works on emulator/not on device" problems with SQL have to do with the file location. QSQLite is not particularly general about how it expects to locate the database file.

    This sequence
    Code:
    	QString dbType("QSQLITE");
    	QString dbName("wdb35.db");
    	db = QSqlDatabase::addDatabase(dbType);
            QFileInfo info(dbName);
            dbName = info.absoluteFilePath().replace("/", "\\");
    	db.setDatabaseName(dbName);   
            if (!db.open()) {
                 QMessageBox::information(0, "", QString::fromAscii("Database error %1").arg(db.lastError().text()));
                 return;
            }
    Will open the DB file even if on other than the C: drive, and with minor modifications will handle other odd cases.

  4. #4
    Regular Contributor
    Join Date
    Oct 2008
    Posts
    323

    Re: Qstring Query ?

    thx danhicksbyron.

Similar Threads

  1. Covert unsigned char to QString
    By jwzeng0312 in forum Qt
    Replies: 3
    Last Post: 2010-06-30, 19:57
  2. how to convet QString into int?
    By jainmonali21 in forum Qt
    Replies: 4
    Last Post: 2010-06-03, 13:26

Posting Permissions

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