Hi!

I tried to add a database using Qt and I got this error:


Please click on the image below to view it in full size

unable to open db.jpg

Here's my code:


void DB::initialize(){
QSqlError err;
QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");

QString str = "DRIVER=%1;UID=%2;Address=%3;"
" DATABASE=%4;TimeOut=3;SERVER=%5";

str = str.arg(DB_DRIVER). \
arg(DB_UID). \
arg(DB_ADDRESS). \
arg(DB_DATABASE). \
arg(DB_SERVER);

db.setDatabaseName(str);
if(db.isValid() == true) printf("VALID\n");
else printf("INVALID\n");

if (!db.open(DB_UID, DB_PASSWORD)) {
err = db.lastError();

if (err.type() != QSqlError::NoError)
QMessageBox::warning(this, tr("Unable to open database"), tr("An error occurred while "
"opening the connection: ") + err.text());
}else{
printf("TRUE\n");
}

}


The db.isValid() returned true. Can I assume that only the userID or password is incorrect? Or is it possible that other provided information (DB_SERVER, DB_DATABASE, etc.) are incorrect?