qt編程中QSqlquery對象作為一個類的成員如何初始化?
//自己設置連接名,不使用默認連接名
if (SdbSqlite.contains("Conn2sqlite"))
{
SdbSqlite = QSqldatabase::database("Conn2sqlite");
}
else
{
SdbSqlite = QSqlDatabase::addDatabase(
"QSQLITE","Conn2sqlite");
}
SdbSqlite.setDatabaseName("FiveChess.database"); //數據庫名稱
定義QSqlDatabase SdbSqlite;并連接sqlite數據庫
QString StrSql1 =
QString("select name,grade,integration,round,victory,defeat,rank"
" from member where account = '%0' and password = '%1';")
.arg(StrAcn,StrPsdOrNew);
QSqlQuery query1(SdbSqlite);
query1.exec(StrSql1);
查詢語句