C++ (Qt)query.bindValue(":name", "'test'");
CREATE TABLE Cans( CANNUM SMALLINT NOT NULL, DTTM TIMESTAMP NOT NULL, CANVALUE DOUBLE PRECISION NOT NULL);
QSqlDatabase DBStoreWrite= QSqlDatabase::addDatabase("QFIREBIRD","DBStoreWrites"); DBStoreWrite.setConnectOptions("CHARSET=WIN1251"); DBStoreWrite.setDatabaseName("DBStore"); DBStoreWrite.open("SYSDBA","masterkey"); QSqlQuery SqlTest(DBStoreWrite); SqlTest.prepare("INSERT INTO Cans (CANNUM,DTTM,CANVALUE) VALUES (:CANNUM,'NOW',:CANVALUE)"); for (int i=0;i<2;i++) { SqlTest.bindValue(0,1); SqlTest.bindValue(1, i); DBStoreWrite.transaction(); SqlTest.exec(); DBStoreWrite.commit(); } DBStoreWrite.close();
C++ (Qt) QSqlDatabase DBStoreWrite= QSqlDatabase::addDatabase("QFIREBIRD","DBStoreWrites"); DBStoreWrite.setConnectOptions("CHARSET=WIN1251"); DBStoreWrite.setDatabaseName("DBStore"); DBStoreWrite.open("SYSDBA","masterkey"); QSqlQuery SqlTest(DBStoreWrite); DBStoreWrite.transaction(); SqlTest.prepare("INSERT INTO Cans (CANNUM,DTTM,CANVALUE) VALUES (:CANNUM,'NOW',:CANVALUE)"); for (int i=0;i<2;i++) { SqlTest.bindValue(0,1); SqlTest.bindValue(1, i); SqlTest.exec(); } DBStoreWrite.commit(); DBStoreWrite.close();