QSqlDatabase db = QSqlDatabase::addDatabase("QODBC"); db.setDatabaseName("DRIVER={SQL Server};SERVER=myserver;DATABASE=mydb"); RDSqlQuery query("SELECT * FROM mytable WHERE age > ?", db); query.bindValue(0, 18); while(query.next()) { int id = query.value("id").toInt(); QString name = query.value("name").toString(); // handle each row of results }
RDSqlQuery query(db); query.prepare("INSERT INTO mytable (id, name) VALUES (?, ?)"); for(int i = 0; i < 10; i++) { query.bindValue(0, i); query.bindValue(1, "Person " + QString::number(i)); query.exec(); }Here, we prepare an RDSqlQuery for inserting rows into a table with two columns. We then execute the query multiple times with different values, using bindValue() to set the parameter values. Based on the use of the `QSqlDatabase` and `QODBC` classes, RDSqlQuery appears to be part of the Qt SQL module, which provides database drivers and tools for working with SQL databases.