static int cCount = 0;
//db.setDatabaseName(dbName);
db.setHostName(host);
db.setPort(port);
if (!db.open(user, passwd)) {
err = db.lastError();
}
else{
conName.
append(QString::number(cCount,
10));
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())//;
{
}
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());
}
To copy to clipboard, switch view to plain text mode
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".
Bookmarks