Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. 'SELECT' was not declared in this scope

'SELECT' was not declared in this scope

Scheduled Pinned Locked Moved Solved General and Desktop
selectsqlqsqlquery
3 Posts 2 Posters 2.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • cxamC Offline
    cxamC Offline
    cxam
    wrote on last edited by
    #1

    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
                             ^
    

    Stay Hungry, Stay Foolish

    1 Reply Last reply
    0
    • A Offline
      A Offline
      alex_malyu
      wrote on last edited by alex_malyu
      #2

      @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" );

      cxamC 1 Reply Last reply
      1
      • A alex_malyu

        @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" );

        cxamC Offline
        cxamC Offline
        cxam
        wrote on last edited by
        #3

        @alex_malyu Thanks a lot

        Stay Hungry, Stay Foolish

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved