PDA

View Full Version : problem while executing Query



jjbabu
27th May 2009, 11:18
I am using QT commercial edition and i installed my OCI driver to access ORACLE db.


static int cCount = 0;


QSqlError err;
QSqlDatabase db = QSqlDatabase::addDatabase(driver, QString("Connection%1").arg(++cCount));
//db.setDatabaseName(dbName);
db.setHostName(host);
db.setPort(port);
if (!db.open(user, passwd)) {
err = db.lastError();
db = QSqlDatabase();
QSqlDatabase::removeDatabase(QString("Connection%1").arg(cCount));
}
else{
conName.append(QString::number(cCount,10));
QSqlQuery query;
query.prepare("INSERT INTO person (id, forename, surname) "
"VALUES (:id, :forename, :surname)");
query.bindValue(":id", 10);
query.bindValue(":forename", "Bart");
query.bindValue(":surname", "Simpson");
if(!query.exec())//;
{
QSqlError err1=query.lastError();
QMessageBox::information(this,"Hi",err1.text());
}

This is the method am using to create connection with my Db and immediately executing the sql query.Using above method i am able to connect with oracle Db with OCI driver and while executing sql query i am receiving error,which states that "Driver not loaded Driver not loaded".

what is the problem? can any one help me....

thanks

spirit
27th May 2009, 11:46
open sqlbrowser which is located on QTDIR/demos/sqlbrowser and check if OCI driver is present and if is it then try to connect to a database using this tool. in that case if OCI driver is not present then you have to build it, read this (http://doc.qtsoftware.com/4.5/sql-driver.html#qoci-for-the-oracle-call-interface-oci) how to do this.