Results 1 to 4 of 4

Thread: Unable to fetch data when searching through select query

  1. #1
    Join Date
    Jan 2008
    Location
    India
    Posts
    31
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Unhappy Unable to fetch data when searching through select query

    void VistaMedia::search()
    {
    QString searchText=searchTextLineEdit->text();
    QSqlQuery query;
    query.prepare("SELECT title FROM mediadetails WHERE title LIKE ' %:title% ' "); query.bindValue(":title",searchText);
    query.exec();
    while(query.next())
    listWidget->addItem(query.value(0).toString());
    QSqlError e=query.lastError () ;
    QMessageBox::information(this,"problem",e.text());
    }



    table details are as :
    mediadetails
    ----------------
    |title|

    F_1.avi
    F_2.avi
    11.dat
    music.dat
    jazz.avi

    i am entering in the search text " f ".
    there is a error message shows "unable to fetch data". what to do????
    @shish

  2. #2
    Join Date
    Jan 2008
    Location
    India
    Posts
    31
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Talking Re: Unable to fetch data when searching through select query

    void VistaMedia::search()
    {
    QString serachText=searchTextLineEdit->text().trimmed();
    int noOfItems=listWidget->count();
    while(noOfItems>0)
    {
    if(!(listWidget->item(noOfItems-1)->text().contains(mname, Qt::CaseInsensitive)))
    {
    listWidget->removeItemWidget ( listWidget->item(noOfItems-1));
    delete listWidget->item(noOfItems-1);
    }
    l--;
    }
    }


    I have solved my problem in another way ,just using listwidget's functions,without using query.its fast and better.Thanks to all replies ....
    @shish

  3. #3
    Join Date
    Jan 2008
    Location
    India
    Posts
    31
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Unable to fetch data when searching through select query

    but i want the solution for previous problem ..................
    becoz now i must fetch data from mysql table.....
    for advance search in which i have to match the entered data with relevent colums specified.....
    so, guys....plzzz suggest me...


    void VistaMedia::search()
    {
    QString searchText=searchTextLineEdit->text();
    QSqlQuery query;
    query.prepare("SELECT title FROM mediadetails WHERE title LIKE ' %:title% ' "); query.bindValue(":title",searchText);
    query.exec();
    while(query.next())
    listWidget->addItem(query.value(0).toString());
    QSqlError e=query.lastError () ;
    QMessageBox::information(this,"problem",e.text());
    }



    table details are as :
    mediadetails
    ----------------
    |title|

    F_1.avi
    F_2.avi
    11.dat
    music.dat
    jazz.avi

    i am entering in the search text " f ".
    there is a error message shows "unable to fetch data". what to do????
    @shish

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Unable to fetch data when searching through select query

    Please, don't post the same question more than once.

Similar Threads

  1. Select query using mysql for searching
    By sinha.ashish in forum Qt Programming
    Replies: 4
    Last Post: 10th April 2008, 06:14
  2. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.