PDA

View Full Version : how can i store and retrieve image & sound in Database



Askar
14th September 2009, 08:14
Dear Friends,
how can i store and retrieve Image and sound files to/from Database.
i can store and retrieve image files to/from database by reading the file contents into byte array and store it into the database, same process is used to retrive from dB.

QFile fileIn ("Beeth.wma");
if (fileIn.open (QIODevice::ReadOnly))
{
QByteArray wBData(fileIn.readAll());
QString DocData.append(wBData);
}

then insert into Tab(....)values(...Docdata);

but this process is not working for sound files. How can i resolve it....


I wondered if anybody gave solution.


Thanks,

Askar

caduel
14th September 2009, 08:27
QString DocData.append(wBData);
what is that supposed to do?

I would use a prepared statement (see QSqlQuery::prepare()) and then bind the QByteArray to it.

Askar
14th September 2009, 08:31
i could not able to bind the QByteArray directly. so what i converted QByteArray to QString before i call bind function