Hi every body ,
I am using Qt4.4.3 , VS2005 . I wrote a code to connect to database . The is as follows .
db.setDatabaseName("appolice");
db.setHostName("localhost");
db.setUserName("root");
db.setPassword("root");
db.setPort(3307);
if(!db.open())
QMessageBox::information(this,
"",
"Database Connection Failed");
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setDatabaseName("appolice");
db.setHostName("localhost");
db.setUserName("root");
db.setPassword("root");
db.setPort(3307);
if(!db.open())
QMessageBox::information(this,"","Database Connection Failed");
To copy to clipboard, switch view to plain text mode
I create one QT GUI app and used this code to connect to database , I am able to connect . But I created one more new Qt GUI app where I used same code to connect to data base but it is not able to connect . I didn't get why it is connecting in one application and why it is failed to connect in another application.
Please help me to make connect .
Regards,
Sudheer.
Bookmarks