quickNitin
16th January 2007, 05:56
I am trying to open a database through Qt . Here is the code.
inline bool createConnection()
{
QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL");
db.setHostName("localhost");
db.setDatabaseName("/home/pgdata/data1");
db.setUserName("pgdata");
db.setPassword("krajesh");
if (!db.open()) {
QMessageBox::warning(0, QObject::tr("Database Error"),
db.lastError().text());
return false;
}
return true;
}
it results in the error. FATAL: coulfd't coonnect to database /home/pgdata/data1.
/home/pgdata/data1 do exists. It is a cluster of database inside it i had created one with default name pgdata. but opening it also results in same name. I can acess and query over it using psql from command prompt. Also same code with QMYSQL works well.
quickNitin
inline bool createConnection()
{
QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL");
db.setHostName("localhost");
db.setDatabaseName("/home/pgdata/data1");
db.setUserName("pgdata");
db.setPassword("krajesh");
if (!db.open()) {
QMessageBox::warning(0, QObject::tr("Database Error"),
db.lastError().text());
return false;
}
return true;
}
it results in the error. FATAL: coulfd't coonnect to database /home/pgdata/data1.
/home/pgdata/data1 do exists. It is a cluster of database inside it i had created one with default name pgdata. but opening it also results in same name. I can acess and query over it using psql from command prompt. Also same code with QMYSQL works well.
quickNitin