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
Forum Updated to NodeBB v4.3 + New Features

'SELECT' was not declared in this scope

Scheduled Pinned Locked Moved Solved General and Desktop
selectsqlqsqlquery
3 Posts 2 Posters 2.1k Views 1 Watching
  • 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.
  • C Offline
    C Offline
    cxam
    wrote on 1 Apr 2016, 21:17 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 1 Apr 2016, 21:31 last edited by alex_malyu 4 Jan 2016, 21:58
      #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" );

      C 1 Reply Last reply 1 Apr 2016, 21:56
      1
      • A alex_malyu
        1 Apr 2016, 21:31

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

        C Offline
        C Offline
        cxam
        wrote on 1 Apr 2016, 21:56 last edited by
        #3

        @alex_malyu Thanks a lot

        Stay Hungry, Stay Foolish

        1 Reply Last reply
        0

        3/3

        1 Apr 2016, 21:56

        • Login

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