Sqlite3 Select statment return no result
-
I wouldn't say it's an Sqlite3 bug (I might be wrong though). From your description you are trying to search in a ASCII column with Arabic chars. You should first convert your Arabic representation of the date into something that's understandable by your database backend.
-
I wouldn't say it's an Sqlite3 bug (I might be wrong though). From your description you are trying to search in a ASCII column with Arabic chars. You should first convert your Arabic representation of the date into something that's understandable by your database backend.
@SGaist No it's not arabic chars ! it's arabic number , read this.
it's the QDate that uses arabic numbers ( even though i've change it to english and it write in english, but it still uses the arabic numbers ! ).
this video is show everything : https://youtu.be/hS7v1KFhOds
-
Are you also inserting data in your database through Qt ?
-
Did you create that database using another sqlite application ?
I'd test again with a database created completely with Qt.
-
Did you create that database using another sqlite application ?
I'd test again with a database created completely with Qt.
@SGaist I think u got lost there :D , and my english isn't that good anyway i will try explain more :
east numbers ( west numbers ) : ٠ (0) , ١ (1), ٢ (2), ٣ (3), ٤ (4), ٥ (5), ٦ (6), ٧ (7), ٨ (8) , ٩ (9) .QDateEdit uses east numbers by default i think that cuz my computer is arabic ! , even if i change the QDateEdit prototype to english the numbers are changed to english but when insert to db it gives in east numbers ( as u can see the video above ) .
QString can recognize tha east numbers
so if u write :QString test = "٢٠١٧"; // output will be 2017so here we put east numbers in QString but when try to print with qDebug() or anything else it will give us the numbers in west form , but if u try to insert the value of test in db it will insert the real value ! the east form .
Sqlite3 can't recognize the east numbers , it will treat it as some char's no more !the table i'm work on it now it uses different method to insert the date it's not uses any QDateEdit ...etc .
but when i want to read i want the user insert the date from QDateEdit , but QDateEdit will use the east numbers and in the table the date column it uses west numbers ! -
so build it as text...
QLocale arabLocal(QLocale::Arabic); const QString dateText = arabLocal.Tostring(ui->deMonth->date().month()) + '/' + arabLocal.Tostring(ui->deMonth->date().year());or
QLocale englLocal(QLocale::English); const QString dateText = englLocal.Tostring(ui->deMonth->date().month()) + '/' + englLocal.Tostring(ui->deMonth->date().year());Depending on whether you want the numbers in arabic or western format
P.S.
never, ever build your queries concatenating unescaped user input. see https://www.w3schools.com/sql/sql_injection.asp -
so build it as text...
QLocale arabLocal(QLocale::Arabic); const QString dateText = arabLocal.Tostring(ui->deMonth->date().month()) + '/' + arabLocal.Tostring(ui->deMonth->date().year());or
QLocale englLocal(QLocale::English); const QString dateText = englLocal.Tostring(ui->deMonth->date().month()) + '/' + englLocal.Tostring(ui->deMonth->date().year());Depending on whether you want the numbers in arabic or western format
P.S.
never, ever build your queries concatenating unescaped user input. see https://www.w3schools.com/sql/sql_injection.asp -
@MrLibya My bad:
QLocale englLocal(QLocale::English); englLocal.setNumberOptions(QLocale::OmitGroupSeparator | englLocal.numberOptions()); QString dateText = englLocal.Tostring(ui->deMonth->date().month()); if(dateText.size()==1) dateText.prepend('0'); dateText += '/' + englLocal.Tostring(ui->deMonth->date().year()); -
@MrLibya My bad:
QLocale englLocal(QLocale::English); englLocal.setNumberOptions(QLocale::OmitGroupSeparator | englLocal.numberOptions()); QString dateText = englLocal.Tostring(ui->deMonth->date().month()); if(dateText.size()==1) dateText.prepend('0'); dateText += '/' + englLocal.Tostring(ui->deMonth->date().year());