QSQL SQLite problem
-
I've a problem with SQLite, when consulting the DB for a User and Pass it just doesn't work), I can ask if the user exist, but not if the password it's correct.
@
QSqlQuery sql;
QString strSql = "SELECT Usuario,Clave,Administrador FROM UsuariosSistema WHERE Usuario=:usuario AND Clave=:clave";
sql.prepare(strSql);
sql.bindValue(":usuario", usuario);
sql.bindValue(":clave", claveHash.toHex());
@this code works in MySQL but not in SQLite, and in SQLite if I do this:
@QSqlQuery sql;
QString strSql = "SELECT Usuario,Clave,Administrador FROM UsuariosSistema WHERE Usuario=:usuario;
sql.prepare(strSql);
sql.bindValue(":usuario", usuario);@it works, but I need to get the password too, am I missing something? the DB has the same content..
-
Please check with that, you got something.
@qDebug()<<sql.lastError().text();@
-
I don't have an error! It just doesn't take the
@claveHash.toHex()@
if I do qDebug() << claveHash.toHex() the result is:
@d033e22ae348aeb5660fc2140aec35850c4da997@
And that's what I have in the DB
@qDebug()<<sql.lastError().text();@ returns nothing " "
-
I see, sorry SQLite can't accept Hex data types.
"SQLite datatypes":http://www.sqlite.org/datatype3.html
You should try to change them into QString to store. -
the method toHex() returns a a QByteArray, so I wasn't casting it to a QString, it works now! thank you so much!! :D
-
[quote author="ron9776" date="1318822074"]1
qDebug()<<sql.lastError().text();[/quote]I don't get it, What were you trying to say? that's the first answer I got
-
QByteArray::toHex() returns another QByteArray. Did you try to convert that into a QString before binding it to the SQL placeholder?
-
[quote author="JessyNay" date="1318822832"][quote author="ron9776" date="1318822074"]1
qDebug()<<sql.lastError().text();[/quote]I don't get it, What were you trying to say? that's the first answer I got
[/quote]
It was a spam account. I removed the post and deleted the user.