Hello.
I am begginer with qsql module and I am trying to insert a new element in a database table. I dont know what i am doing wrong, because the conection is not opened. I am working with Windows 98.
This is the code:
db.setHostName("localhost");
db.setDatabaseName("DRIVER={Microsoft Access Driver (*.mdb)};FIL={MS Access};DBQ=C:\\Documents and Settings\\user1\\bbdd.mdb");
if ( db.open() ) {
// Database successfully opened; we can now issue SQL commands.
target.exec( "INSERT INTO Equipo ( serialNumber,uniNumber,description ) VALUES ( 1213,3423,sdfahsoew )" );
}
db.close();
QSqlDatabase db;
db = QSqlDatabase::addDatabase( "QODBC" );
db.setHostName("localhost");
db.setDatabaseName("DRIVER={Microsoft Access Driver (*.mdb)};FIL={MS Access};DBQ=C:\\Documents and Settings\\user1\\bbdd.mdb");
if ( db.open() ) {
// Database successfully opened; we can now issue SQL commands.
QSqlQuery target;
target.exec( "INSERT INTO Equipo ( serialNumber,uniNumber,description ) VALUES ( 1213,3423,sdfahsoew )" );
}
db.close();
To copy to clipboard, switch view to plain text mode
and it has never gone into the condition if.
Cheers, and thank you in advance.
Bookmarks