PDA

View Full Version : Read blob fields from a database with the odbc driver



Andrewgaven
14th January 2013, 02:40
Greetings, I'm trying to create a program that automatically update a blob field of a table, i know that the data in the blob field is text but don't know much more about it.
is there any way to read/update this field? this is my code so far:


void conecta2::retrieveblob()
{
conectdbisam();
QByteArray blob;
QString line;
QString line2;
QString tabla = "sfixed";
QString pointer = "55542";
int h,k,o;
h=0;
k=1; //this is the code column that should match with "pointer"
o=4; //this is the blob column
if(db.open())
{
QSqlQuery qry;
if(qry.exec("SELECT * FROM "+tabla))
{
QSqlRecord rec = qry.record();
columna = rec.fieldName(k);
}
if(qry.exec("SELECT * FROM "+tabla+" WHERE "+columna+" = '"+pointer+"'"))
{
while(qry.next())
{
blob= qry.value(o).toByteArray();
line2 = line.fromAscii(blob);
qDebug() << "line blob "+line2;
h++;
if (h==500)
break;
}
}
}
else
{
qDebug() << "Error =" << db.lastError().text();
}
}

this return "line blob " meaning that the string line2 is empty, what am I doing wrong?
Thanks in advance