From 77247f927e9d77d9ac466279862af09198a8260c Mon Sep 17 00:00:00 2001 From: Msy-msu <2200456405@qq.com> Date: Mon, 9 Jan 2023 16:17:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E7=99=BB=E5=BD=95=E5=8C=B9=E9=85=8D=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TcpServer.pro.user | 46 +++++++++++++++++++++++++++++++++++++++++++--- database.cpp | 22 ++++++++++------------ 2 files changed, 53 insertions(+), 15 deletions(-) diff --git a/TcpServer.pro.user b/TcpServer.pro.user index f0024c8..864b31f 100644 --- a/TcpServer.pro.user +++ b/TcpServer.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId @@ -94,7 +94,7 @@ Desktop Qt 6.2.3 MinGW 64-bit Desktop Qt 6.2.3 MinGW 64-bit qt.qt6.623.win64_mingw_kit - 1 + 2 0 0 @@ -179,7 +179,47 @@ Qt4ProjectManager.Qt4BuildConfiguration 2 - 2 + + C:\Users\25761\Desktop\build-TcpServer-Desktop_Qt_6_2_3_MinGW_64_bit-111 + C:/Users/25761/Desktop/build-TcpServer-Desktop_Qt_6_2_3_MinGW_64_bit-111 + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + 1112 + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + + 3 0 diff --git a/database.cpp b/database.cpp index 72688d3..94242ae 100644 --- a/database.cpp +++ b/database.cpp @@ -150,25 +150,23 @@ bool DataBase::match(QString name, QString pwd) QSqlQuery query(db_); query.prepare(sql); query.bindValue(":name",QVariant(name)); - if(!query.exec()) + if(query.exec()) { - qDebug() << "match fail" << db_.lastError().text(); - return false; - } - - //匹配密码 - if(query.next()) - { - qDebug() << query.value(1).toString(); - if(!(pwd == query.value(1).toString())) + //匹配密码 + if(query.next()) { - return false; + qDebug() << query.value(1).toString(); + if(pwd == query.value(1).toString()) + { + return true; + } } } + //关闭数据库 db_.close(); - return true; + return false; }