PDA

View Full Version : Not able to execute in Release Mode



sudheer168
18th March 2009, 07:37
Hello ,
I have a small problem with Qt. I am not able to run a simple database program in Relese mode but it works in Debug mode. I have some other widgets which work only in release mode so i have to make it work in release mode itself. I am using Qt integrated with VS .Net (2003). When i run it in release mode it throws an error which is given in Sqlite db connection.h file that (connection is not established). But it works fine in Debug mode i don't get any error. Pls help me out with this problem .


Thank You

aamer4yu
18th March 2009, 10:02
Check for variable initializations and memory handling.

Usually in debug mode, variables are intialised with default value, but in release it will give garbage. Most common mistake I have encountered :D

sudheer168
18th March 2009, 10:37
Hey i checked all the linker paths Include paths every thing is in the right path but still i get the same problem. In debug mode even the database file is created but in release mode after the build is done there is no error exactly but the database file is not created. This is the connection.h code



#ifndef CONNECTION_H
#define CONNECTION_H

#include <QtGui/QMainWindow>
#include <QtSql>
#include <QMessageBox>
#include <QTableView>

inline bool createConnection()
{
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName(" LPSC");
if (!db.open())
{
QMessageBox::critical(0, qApp->tr("Cannot open database"),
qApp->tr("Unable to establish a database connection.\n"
"This example needs SQLite support. Please read "
"the Qt SQL driver documentation for information how "
"to build it.\n\n"
"Click Cancel to exit."), QMessageBox::Cancel);
return false;
}
}
#endif


I even get this warning when i run it on release mode

warning C4715: 'createConnection' : not all control paths return a value

Pls tell me if i am missing some thing or going any where wrong.

Thank You

spirit
18th March 2009, 10:54
rewrite this function like this


inline bool createConnection()
{
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName(" LPSC");
if (!db.open())
{
QMessageBox::critical(0, qApp->tr("Cannot open database"),
qApp->tr("Unable to establish a database connection.\n"
"This example needs SQLite support. Please read "
"the Qt SQL driver documentation for information how "
"to build it.\n\n"
"Click Cancel to exit."), QMessageBox::Cancel);
return false;
}
return true;
}

sudheer168
18th March 2009, 12:58
Hey i solved the problem thanks for the reply.
I had installed qt in C drive and VS.net 2003 in D drive i uninstalled the qt and installed it in D drive it is working fine now.

thank you