thank you for your reply
i have question ,can you help me
i want to write a below code, but I do not know how to coding them,plz help me
............
if(warning == 0)
{
warning=1;
start_time=getCurrentDateTime(); //i have write a function to get time and i call it here
insert_to_db(start_time, "high value", "...");
current_id= ???????
}
}
else
{
if(warning==1)
{
warning=0;
end_time=getCurrentDateTime();
update_to_db(end_time,current_id);//i want to update only update end time at above record where ID is ID at insert_to_db(start_time, "high value", "...");
}
............
if(warning == 0)
{
warning=1;
start_time=getCurrentDateTime(); //i have write a function to get time and i call it here
insert_to_db(start_time, "high value", "...");
current_id= ???????
}
}
else
{
if(warning==1)
{
warning=0;
end_time=getCurrentDateTime();
update_to_db(end_time,current_id);//i want to update only update end time at above record where ID is ID at insert_to_db(start_time, "high value", "...");
}
To copy to clipboard, switch view to plain text mode
and this is a update function that i write
void class
::update_to_db(QString finish_time,
int id
) {
query.prepare("update db_table set finish_time= :finish_time" "when id= :id");
query.bindValue(":id",id);
query.bindValue(":finish_time",finish_time);
if(!query.exec())
{
}
}
void class::update_to_db(QString finish_time,int id)
{
QSqlQuery query;
query.prepare("update db_table set finish_time= :finish_time" "when id= :id");
query.bindValue(":id",id);
query.bindValue(":finish_time",finish_time);
if(!query.exec())
{
throw QSqlError();
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks