PDA

View Full Version : Issues regarding QMySql drivers and mysql database



bera82
25th March 2006, 05:52
Hi,

I am using QT 3.3 , I would like to know if there are any issues with retrieving values from mysql database. I have been trying to retrieve values in my qt application but it jus doesn work... it returns null value!! My parameters in the query are QDateTime datatypes. but i pass it as a string in the query and compare it against the database. The corresponding coloumn in the database is of datatype(datetime)!!
The same query works when i query the database directly from console!!
please help!!

regards
Bera

wysota
25th March 2006, 09:01
Can we see the code?

Alienxs
10th August 2006, 17:50
man the thing is you have to pass the Qdate to Qstring and then save it into the DB there is a funtion that allows you to do that and you have to get the format you want and that format has to fix to mysql date format which is yyyy.MM.DD and then save it into the data base, if wanna get it back you just have to do this:

QSqlQuery Consult("select year(date_field_into_your table) month(date_field_into_your table) day(date_field_into_your table) from your table");
QString y, m, d;
while (Consult.next())
{
y=Consult.value(0).toString();
m=Consult.value(1).toString();
d=Consult.value(2).toString();
}
yourDateLineEdit->setDate(y,m,d);

and that's all that's the way you could get the date back if you have anytrouble insertting the date into the database let me know