if (SdbSqlite.contains("Conn2sqlite"))
{
SdbSqlite = QSqlDatabase::database("Conn2sqlite")
}
else
{
SdbSqlite = QSqlDatabase::addDatabase(
"QSQLITE","Conn2sqlite")
}
SdbSqlite.setDatabaseName("FiveChess.database") //数据库名称
这是连接
if (SdbSqlite.open()){
int RltRowNumber = 0 //查询出来的结果列数
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)
while (query1.next())
{
if (SdbSqlite.driver()->hasFeature(QSqlDriver::QuerySize))
{
//速度快
RltRowNumber = query1.size()
}
else
{
//速度很慢
//实际执行的是这个
query1.last()
RltRowNumber = query1.at() + 1
}
}
SdbSqlite.close()
}
这是查询
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)