开发者

Inserting binary data via QSQL

How to insert binary data to table "test" from "database" with 2 columns text "name" and bin "pic"

开发者_StackOverflow
QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL");
 db.setUserName("user");
 db.setPassword("pwd");
 db.setPort(1234);
 db.setDatabaseName("database");


You can have a look at http://www.java2s.com/Code/Cpp/Qt/UsingsqldatabasefromQt.htm snippets

First you need to open the DB db.open();

One way would be

QSqlQuery query;
query.prepare("INSERT INTO test (name, pic) "
              "VALUES (:name, :pic)");
query.bindValue(":name", "Bart");
query.bindValue(":pic", "Bart.jpg");
query.exec();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜