harleyskater
24th June 2010, 20:03
I have built a similar project in C++ in Visual Studios. I am trying to convert as much of this project as I can into QT because the enviornment in which this application is needed has expanded to MAC OS.
All of this compiles but I know there is an issue somewhere in the code becasue my query is not returning any rows. which brings the main issue. I can not for the life of me figure out how to set breakpoints in Visual Studios so I can see what is happening with my variables usename and password
Theres no real reason for me to post my code because my real question is about debugging but I thought there might be something other than a breakpoint that could be done to check the variable so I included it :P
#include "thewge.h"
#include "ui_thewge.h"
#include <QtGui/QApplication>
#include <QSignalMapper>
#include <QPushButton>
#include <windows.h>
#include <iostream>
#include "md5.h"
#include "mysql++.h"
TheWGE::TheWGE(QWidget *parent, Qt::WFlags flags)
: QMainWindow(parent, flags)
{
ui.setupUi(this);
QObject::connect(ui.LoginBtn, SIGNAL(clicked()), this, SLOT(login()));
}
TheWGE::~TheWGE()
{
//ui.usrLineEdit->clear();
//ui.pwdLineEdit->clear();
}
void TheWGE::login()
{
if (ui.usrLineEdit->text().trimmed().isEmpty() )
{
ui.usrLineEdit->setFocus();
}
else if (ui.pwdLineEdit->text().trimmed().isEmpty() )
{
ui.pwdLineEdit->setFocus();
}
mysqlpp::Connection con(false);
if (!con.connect("Database", "host", "username", "password"))
{
qApp->exit(0);
}
// Retrieve a subset of the sample stock table set up by resetdb
mysqlpp::Query query = con.query();
QString Qstr1 = ui.usrLineEdit->text();
QString Qstr2 = ui.pwdLineEdit->text();
char *acsUserName = new char[ Qstr1.length() + 1 ]; // + 1 for zero in the end of string
memcpy( acsUserName, Qstr1.toUtf8().constData(),Qstr1.length() );
char *acsPassword = new char[ Qstr2.length() + 1 ]; // + 1 for zero in the end of string
memcpy( acsPassword, Qstr2.toUtf8().constData(), Qstr2.length() );
query << "SELECT username, password FROM wge_db_user WHERE username = '" << acsUserName << "' and password = '" << md5(acsPassword) << "'";
mysqlpp::StoreQueryResult res = query.store();
mysqlpp::Row row;
delete []acsUserName;
delete []acsPassword;
if (res.num_rows() > 0)
{
qApp->exit(0);
//goodlogin - show new form and hide this form
}
else
{
//qApp->exit(0);
//badlogin
}
mysqlpp::Connection::thread_end();
return;
}
All of this compiles but I know there is an issue somewhere in the code becasue my query is not returning any rows. which brings the main issue. I can not for the life of me figure out how to set breakpoints in Visual Studios so I can see what is happening with my variables usename and password
Theres no real reason for me to post my code because my real question is about debugging but I thought there might be something other than a breakpoint that could be done to check the variable so I included it :P
#include "thewge.h"
#include "ui_thewge.h"
#include <QtGui/QApplication>
#include <QSignalMapper>
#include <QPushButton>
#include <windows.h>
#include <iostream>
#include "md5.h"
#include "mysql++.h"
TheWGE::TheWGE(QWidget *parent, Qt::WFlags flags)
: QMainWindow(parent, flags)
{
ui.setupUi(this);
QObject::connect(ui.LoginBtn, SIGNAL(clicked()), this, SLOT(login()));
}
TheWGE::~TheWGE()
{
//ui.usrLineEdit->clear();
//ui.pwdLineEdit->clear();
}
void TheWGE::login()
{
if (ui.usrLineEdit->text().trimmed().isEmpty() )
{
ui.usrLineEdit->setFocus();
}
else if (ui.pwdLineEdit->text().trimmed().isEmpty() )
{
ui.pwdLineEdit->setFocus();
}
mysqlpp::Connection con(false);
if (!con.connect("Database", "host", "username", "password"))
{
qApp->exit(0);
}
// Retrieve a subset of the sample stock table set up by resetdb
mysqlpp::Query query = con.query();
QString Qstr1 = ui.usrLineEdit->text();
QString Qstr2 = ui.pwdLineEdit->text();
char *acsUserName = new char[ Qstr1.length() + 1 ]; // + 1 for zero in the end of string
memcpy( acsUserName, Qstr1.toUtf8().constData(),Qstr1.length() );
char *acsPassword = new char[ Qstr2.length() + 1 ]; // + 1 for zero in the end of string
memcpy( acsPassword, Qstr2.toUtf8().constData(), Qstr2.length() );
query << "SELECT username, password FROM wge_db_user WHERE username = '" << acsUserName << "' and password = '" << md5(acsPassword) << "'";
mysqlpp::StoreQueryResult res = query.store();
mysqlpp::Row row;
delete []acsUserName;
delete []acsPassword;
if (res.num_rows() > 0)
{
qApp->exit(0);
//goodlogin - show new form and hide this form
}
else
{
//qApp->exit(0);
//badlogin
}
mysqlpp::Connection::thread_end();
return;
}