The single quote around the name is missing in the second code block. Try this
//Note: CSQLUsers::AL_PUPIL is "1", an intenger
QSqlQuery data
(QString("SELECT id FROM users WHERE iaccesslevel=%1 AND sname = '%2' ") .
arg(CSQLUsers
::AL_PUPIL) .
arg(name
),
*pointer_my_database
->GetDBPtr
());
bool test1 = data.first();
bool test2 = data.isValid();
bool test3 = data.isSelect();
//Note: CSQLUsers::AL_PUPIL is "1", an intenger
QString name = 'Alex';
QSqlQuery data(QString("SELECT id FROM users WHERE iaccesslevel=%1 AND sname = '%2' ") .arg(CSQLUsers::AL_PUPIL) .arg(name), *pointer_my_database->GetDBPtr());
bool test1 = data.first();
bool test2 = data.isValid();
bool test3 = data.isSelect();
To copy to clipboard, switch view to plain text mode
Bookmarks