[solved]qt sql insert statement system not working
-
Try this codesnippet:
@
void YourClass::init()
{
//...
initDB("../../../db/mydb.db3"); // of course your db path goes here
//...
}void YourClass::initDB(QString dbPath)
{
vc2DB = QSqlDatabase::addDatabase("QSQLITE");
vc2DB.setDatabaseName(dbPath);
vc2DB.open();
QSqlQuery query;
query.exec("PRAGMA foreign_keys = ON;");
bool b = query.exec("select id from role where code = 'SU'");
if (!b) {
std::cerr << "Failed to open database: " << dbPath.toAscii().data() << std::endl;
exit(-1);
}
}
@ -
there is not db path set @broadpeak
-
[quote author="developer" date="1353499828"]there is not db path set @broadpeak[/quote]
What? I don't understand this.
But! If the open() function can't open your database, it will open with the given name an another database in QSQLITE! See your databaseS.
-
ohhhhhhhhhh acutally its working with setting url a different databse opens and with just typing passwordmanager as databse name it works actaully the problem is with the table view thanks all problem solved i tried select staement and i got the result