MySql Select statement
General and Desktop
3
Posts
2
Posters
1.3k
Views
1
Watching
-
Hello,
I'm new to QT and have trouble with my first application. I set up a mysql database connection which works perfectly fine for statements like "Update" and "Insert" but not for "Select".
I want to check whether a specific data is already existing in my database:
@QSqlQuery qry1(QSqlDatabase::database("Editor"));
qry1.prepare("SELECT * FROM boardgame WHERE name='testspiel5'");
int counter = 0;
while(qry1.next())
counter++;
if(counter)
already exists@I've also tried to use @if(qry1.first())@
My counter is always zero but testspiel5 exists in my db. If I run the statement above directly in phpmyadmin it shows 1 row as expected. But not in my program.
Best regards.
-
Thank you chrho, that solved my issue!