QSqlDatabase database = QSqlDatabase::addDatabase("QODBC");
database.setDatabaseName("DRIVER={Microsoft Access Driver (*.mdb)};FIL={MSAccess};DBQ=Database.mdb");
database.open();
QMessageBox::information(this, "1212321123123213123123", database.lastError().text());
QSqlQuery readPassword("SELECT * FROM password WHERE username=:username");
readPassword.bindValue(":username", ui->lineEdit_2->text());
readPassword.exec();
if(ui->lineEdit->text().isEmpty() || ui->lineEdit_2->text().isEmpty())
{
QMessageBox::information(this,"Hata", QString::fromUtf8("Fill in the blanks!"));
database.close();
this->show();
}
else
{
bool yes = false;
while(readPassword.next())
{
QString string = readPassword.value(0).toString();
QString string1 = readPassword.value(1).toString();
if(string == ui->lineEdit->text() && string1 == ui->lineEdit_2->text())
{
database.close();
notTakip.show();
notTakip.setPermitedUsername(ui->lineEdit_2->text(), readPassword.value(2).toString().toInt());
notTakip.prepareNotTakip();
yes = true;
this->close();
break;
}
}
if(yes == false)
{
QMessageBox::information(this, "Error", readPassword.lastError().text());
QMessageBox::information(this,"Error", QString::fromUtf8("Wrong username or password!"));
ui->lineEdit->clear();
database.close();
this->show();
}
}
Bookmarks