title: Qt: SELECT-Query to PostgreSQL-Server always responds with NULL
body: <p>I recently started with the Qt Creator and C++ and wanted to use a PostgreSQL database for my needs. So I figured out how to get the driver, included all the tags needed and started executing some querys.</p>
  
  <p>I created new tables, inserted some data, updated them afterwards. It all worked just fine, until I tried to simply select some rows. The query just ended without an error-message and a response of NULL.</p>
  
  <p>The command was a simple <code>SELECT</code>-Command:</p>
  
  <pre><code>query = db.exec("SELECT id FROM users WHERE name = 'Testuser';");
  </code></pre>
  
  <p>But a basic <code>SELECT</code> doesn't work either:</p>
  
  <pre><code>query = db.exec("SELECT * FROM users;");
  </code></pre>
  
  <p>If I now copy exactly this query and put it as a SQL-Statement directly into pgAdmin, it works just fine and responses with the user-id.</p>
  
  <p>I tried quotation marks for the tablename, I tried the full row-names (<code>SELECT users.id FROM public.users WHERE users.name = 'Testuser';</code>) and large and small letters because of some tips from google - nothing worked.</p>
  
  <p>Every query works just fine, but if I try a <code>SELECT</code>, it just always responses with NULL. Although every single of this <code>SELECT</code>-Querys works just fine in pgAdmin.</p>
  
  <p>Has anyone an idea?</p>
  
  <p>The following tags are used:</p>
  
  <pre><code>#include &lt;QDebug&gt;
  #include &lt;QtCore/QCoreApplication&gt;
  #include &lt;QtSql/QPSQLDriver&gt;
  #include &lt;QSqlDatabase&gt;
  #include &lt;QSqlQuery&gt;
  #include &lt;QCryptographicHash&gt;
  #include &lt;QSqlError&gt;
  </code></pre>
  
  <p>The full code looks like this:</p>
  
  <pre><code>QString response;
  QSqlQuery query;
  QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL");
  
  db.setHostName("127.0.0.1");
  db.setPort(5432);
  db.setDatabaseName("postgres");
  db.setUserName("postgres");
  db.setPassword("password");
  
  if (db.open())
  {
      query = db.exec("SELECT id FROM users WHERE name = 'Testuser';");
      response = query.value(0).toString();
  }
  
  db.close();
  </code></pre>