homestead.h
#ifndef HOMESTEAD_H
#define HOMESTEAD_H
#include <QMainWindow>
.....
{
Q_OBJECT
public:
....
....
...
}
#ifndef HOMESTEAD_H
#define HOMESTEAD_H
#include <QMainWindow>
class homestead : public QMainWindow
.....
{
Q_OBJECT
public:
homestead(QWidget *parent = 0);
....
QSqlQuery persQry;
....
...
}
To copy to clipboard, switch view to plain text mode
and
homestead.cpp
/*
Program: homestead.cpp
*/
#include "homestead.h"
#include "wholenamedlg.h"
#include "historydialog.h"
...
ui.setupUi(this); // draw the gui interface
...
// create global query objects
...
}
void homestead::searchAll() {
.....
...
if (ui.rbProprtyID->isChecked()) {
// user is searching for property id
requestString.append(" in Property");
ui.leStatus->setText(requestString);
queryStr = this->propPIDqryStr; // default property id select
queryStr.append(ui.leSearch->text()); // append property id
propQry.clear();
propQry.exec(queryStr);
if (propQry.first()){
// found property record, now fetch associated persinfo record
foundProp = true;
queryStr = this->persPIDqryStr;
queryStr.append(ui.leSearch->text());
persQry.clear();
persQry.exec(queryStr);
if (persQry.first()) {
foundPers = true;
}
...
}
...
/*
Program: homestead.cpp
*/
#include "homestead.h"
#include "wholenamedlg.h"
#include "historydialog.h"
...
homestead::homestead(QWidget *parent) : QMainWindow(parent) {
ui.setupUi(this); // draw the gui interface
...
// create global query objects
QSqlQuery persQry;
...
}
void homestead::searchAll() {
.....
QString queryStr = "";
...
if (ui.rbProprtyID->isChecked()) {
// user is searching for property id
requestString.append(" in Property");
ui.leStatus->setText(requestString);
queryStr = this->propPIDqryStr; // default property id select
queryStr.append(ui.leSearch->text()); // append property id
propQry.clear();
propQry.exec(queryStr);
if (propQry.first()){
// found property record, now fetch associated persinfo record
foundProp = true;
queryStr = this->persPIDqryStr;
queryStr.append(ui.leSearch->text());
persQry.clear();
persQry.exec(queryStr);
if (persQry.first()) {
foundPers = true;
}
...
}
...
To copy to clipboard, switch view to plain text mode
and main.cpp
.....
int main( int argc, char * argv[] ) {
app.setQuitOnLastWindowClosed(false);
dlgLogin dlg;
if( dlg.
exec() == QDialog::Accepted ){ hapdb.setHostName(DBHOST);
hapdb.setDatabaseName(DBNAME);
hapdb.setUserName(dlg.dui.leUserName->text());
hapdb.setPassword(dlg.dui.leUserPassword->text());
if ( hapdb.open() ) {
homestead ht;
ht.RevID = dlg.dui.leUserName->text();
ht.show();
app.setQuitOnLastWindowClosed(true);
return app.exec();
} else {
strRejected
= QString("The Login was rejected because: %1").
arg(hapdb.
lastError().
text()).
toLatin1();
QMessageBox::information(0,
"Login Rejected!",strRejected,
return 1;
}
} else {
strRejected
= QString("User Canceled the login!").
toLatin1();
QMessageBox::information(0,
"Login Rejected!",strRejected,
return 2;
}
}
.....
int main( int argc, char * argv[] ) {
QString strRejected = "";
QApplication app(argc, argv);
app.setQuitOnLastWindowClosed(false);
dlgLogin dlg;
if( dlg.exec() == QDialog::Accepted ){
QSqlDatabase hapdb = QSqlDatabase::addDatabase(DBDRIVER);
hapdb.setHostName(DBHOST);
hapdb.setDatabaseName(DBNAME);
hapdb.setUserName(dlg.dui.leUserName->text());
hapdb.setPassword(dlg.dui.leUserPassword->text());
if ( hapdb.open() ) {
homestead ht;
ht.RevID = dlg.dui.leUserName->text();
ht.show();
app.setQuitOnLastWindowClosed(true);
return app.exec();
} else {
strRejected = QString("The Login was rejected because: %1").arg(hapdb.lastError().text()).toLatin1();
QMessageBox::information(0,"Login Rejected!",strRejected,
QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
return 1;
}
} else {
strRejected = QString("User Canceled the login!").toLatin1();
QMessageBox::information(0,"Login Rejected!",strRejected,
QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
return 2;
}
}
To copy to clipboard, switch view to plain text mode
A cursor is created each time "persQry.exec(queryStr): is executed but it is not released by persQry.clear*() the next time the searchAll function is called.
The Oracle cursor count continues to increase until MAX_OPEN_CURSOR is reached.
Bookmarks