QSqlQuery query;query.exec(QString("UPDATE table SET binaryColumun = %1 WHERE row_id = 1").arg(QString(bitArray));
query.prepare("UPDATE table SET binaryColumn=:bit WHERE id = :id");query.bindValue(":bit", bitArr, QSql::Binary);query.bindValue(":id", idInt,);query.exec();
QString bitArrStr;for(int i=0; i<bitArr.count(); ++i){ if(bitArr.testBit(i)) str.append("1"); else str.append("0");}QSqlQuery query;query.exec(QString("UPDATE table SET binaryColumun = %1 WHERE id = 1").arg(bitArrStr));
C++ (Qt)query.bindValue(":bit", idInt,);
C++ (Qt)Qvariant data = QVariant(/*QBitArray*/);QString s ;QString res ;QByteArray buf = data.toByteArray();QString dta = "NULL";for (int i = 0 ; i < buf.count() ; i++){ s = QString::number(buf[i],16).toUpper(); if (s.length() < 2) s = "0" + s; s = s.right(2); res += s; }dta = QString("X'%1'").arg(res);query.bindValue(":bit", dta);
QSqlQuery query; query.exec(QString("SELECT bit FROM table WHERE id = 1")); if(query.next()) { QBitArray bitArr(240); bitArr=(query.value(0).toBitArray()); qDebug()<<&bitArr; qDebug()<<bitArr.size(); }
0xbfffe7b4 0
C++ (Qt)...if (query.first())....
C++ (Qt) QSqlQuery query; query.exec(QString("SELECT bit FROM table WHERE id = 1")); if(query.next()) { QBitArray bitArr = query.record().value("bit").toBitArray(); ... }