Fixed cursor's query the database.
Database opening, insertion to DB has been fixed.