when I build in debug mode everything is fine... but when in release mode this error coming up...
btw in application output i found this...
Starting C:\Users\beethoven07\Documents\QT programming\loginform-build-Desktop_Qt_5_0_1_MSVC2010_32bit-Release\release\loginform.exe...
The program has unexpectedly finished.
C:\Users\beethoven07\Documents\QT programming\loginform-build-Desktop_Qt_5_0_1_MSVC2010_32bit-Release\release\loginform.exe exited with code 62097
this my complete code...
loginform.pro
#-------------------------------------------------
#
# Project created by QtCreator 2013-02-21T10:56:20
#
#-------------------------------------------------
QT += core gui sql
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = loginform
TEMPLATE = app
SOURCES += main.cpp\
dialog.cpp
HEADERS += dialog.h
FORMS += dialog.ui
#-------------------------------------------------
#
# Project created by QtCreator 2013-02-21T10:56:20
#
#-------------------------------------------------
QT += core gui sql
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = loginform
TEMPLATE = app
SOURCES += main.cpp\
dialog.cpp
HEADERS += dialog.h
FORMS += dialog.ui
To copy to clipboard, switch view to plain text mode
dialog.h
#ifndef DIALOG_H
#define DIALOG_H
#include <QDialog>
#include <QDebug>
#include <QtSql>
#include <QMessageBox>
#include <QFileInfo>
namespace Ui {
class Dialog;
}
{
Q_OBJECT
public:
explicit Dialog
(QWidget *parent
= 0);
~Dialog();
private slots:
void on_btnClear_clicked();
void on_btnLogin_clicked();
private:
Ui::Dialog *ui;
};
#endif // DIALOG_H
#ifndef DIALOG_H
#define DIALOG_H
#include <QDialog>
#include <QDebug>
#include <QtSql>
#include <QMessageBox>
#include <QFileInfo>
namespace Ui {
class Dialog;
}
class Dialog : public QDialog
{
Q_OBJECT
public:
explicit Dialog(QWidget *parent = 0);
~Dialog();
private slots:
void on_btnClear_clicked();
void on_btnLogin_clicked();
private:
Ui::Dialog *ui;
QSqlDatabase myDB;
};
#endif // DIALOG_H
To copy to clipboard, switch view to plain text mode
dialog.cpp
#include "dialog.h"
#include "ui_dialog.h"
#define path_to_db "C:/Users/beethoven07/Documents/myDbVic/myDBvic.s3db"
ui(new Ui::Dialog)
{
ui->setupUi(this);
myDB.setDatabaseName (path_to_db);
if(checkFile.isFile())
{
if(myDB.open())
{
ui->lblStatus->setText("berhasil konek database");
}
}else
{
ui->lblStatus->setText("nda ta konek di database :(");
}
}
Dialog::~Dialog()
{
delete ui;
qDebug()<< "keluar dari database pada waktu program di matikan";
myDB.close();
}
void Dialog::on_btnClear_clicked()
{
ui->txtPassword->setText("");
ui->txtUsername->setText("");
}
void Dialog::on_btnLogin_clicked()
{
username = ui->txtUsername->text();
password = ui->txtPassword->text();
if(!myDB.isOpen()) {
qDebug() << "No connection to DB :(";
return;
}
if(qry.exec("SELECT username, password, Role FROM loginform WHERE username='" + username +
"\' AND password=\'" + password + "\'"))
{
if(qry.next())
{
ui->lblStatus ->setText("username dan password benar");
QString msg
= "username = " +qry.
value(0).
toString() + "\n" + "password = " +qry.value(1).toString() + "\n" +
"role = " +qry.value(2).toString();
} else {
ui->lblStatus->setText("Sala Password atau username bego");
}
}
}
#include "dialog.h"
#include "ui_dialog.h"
#define path_to_db "C:/Users/beethoven07/Documents/myDbVic/myDBvic.s3db"
Dialog::Dialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::Dialog)
{
ui->setupUi(this);
myDB = QSqlDatabase::addDatabase ("QSQLITE");
myDB.setDatabaseName (path_to_db);
QFileInfo checkFile (path_to_db);
if(checkFile.isFile())
{
if(myDB.open())
{
ui->lblStatus->setText("berhasil konek database");
}
}else
{
ui->lblStatus->setText("nda ta konek di database :(");
}
}
Dialog::~Dialog()
{
delete ui;
qDebug()<< "keluar dari database pada waktu program di matikan";
myDB.close();
}
void Dialog::on_btnClear_clicked()
{
ui->txtPassword->setText("");
ui->txtUsername->setText("");
}
void Dialog::on_btnLogin_clicked()
{
QString username, password;
username = ui->txtUsername->text();
password = ui->txtPassword->text();
if(!myDB.isOpen()) {
qDebug() << "No connection to DB :(";
return;
}
QSqlQuery qry;
if(qry.exec("SELECT username, password, Role FROM loginform WHERE username='" + username +
"\' AND password=\'" + password + "\'"))
{
if(qry.next())
{
ui->lblStatus ->setText("username dan password benar");
QString msg = "username = " +qry.value(0).toString() + "\n" +
"password = " +qry.value(1).toString() + "\n" +
"role = " +qry.value(2).toString();
QMessageBox::warning(this, "Login berhasil", msg);
} else {
ui->lblStatus->setText("Sala Password atau username bego");
}
}
}
To copy to clipboard, switch view to plain text mode
main.cpp
#include "dialog.h"
#include <QApplication>
int main(int argc, char *argv[])
{
Dialog w;
w.show();
return a.exec();
}
#include "dialog.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Dialog w;
w.show();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
thx....
Bookmarks