'SELECT' was not declared in this scope



  • Hi, I'm trying to make a search on SQL so I declared 3 variables which are introduced by the user, these variables are "nombre", "curso" and "grupo" so I need to search on my DB (sqlite3) using these 3 variables so I made the following query statement

    QSqlQuery query;
    query.exec(SELECT * FROM usuarios
    WHERE Nombre=nombre
    AND Curso=curso, Grupo=grupo);
    

    (The names of my columns are "Nombre", "Curso" and "Grupo" and the variables are the same but in lowercase)

    Unfortunately it returns the following error:

    1: error: 'SELECT' was not declared in this scope
         query.exec(SELECT * FROM usuarios
                    ^
    
    2: error: 'FROM' was not declared in this scope
         query.exec(SELECT * FROM usuarios
                             ^
    


  • @cxam said:

    query.exec(SELECT * FROM usuarios

    It has to be QString or type which can be implicitly converted to it. Like:

    query.exec("SELECT * FROM usuarios" );



  • @alex_malyu Thanks a lot


Log in to reply
 

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