PDA

View Full Version : store and retrieve binary data to/from remote sqlserver's image field



Askar
19th September 2009, 08:07
--------------------------------------------------------------------------------

Dear Friends ,
I need to store and retrieve binary data from remote sql server's image field. now i can store binary value into remote server by simply simply reading the source file sontent into byte array and store that byte array content into a Qstring while usnig insert statement.
/************code***********/
wBData is a byte array in which i read source file content
QString s1(wBData);
net.get("http://192.168.0.220/clancor?sql=insert+into+blob+(sno,photo)+values+(4 ,'"+ s1 +"')&root=blobinsert"
/*************************/

while retrieving sql server gives image field as a Binary base Encoded format i tried to docode.but decoded value does not creates original file i saved into the database


/********code**************/
QByteArray wBData1;
net.get("http://192.168.0.220/clancor?sql=select+photo+from+blob+where+sno+=+4+F OR+XML+RAW,+BINARY+BASE64&root=blobinsert&contentt ype=text/xml")

wBData1.append(xml.attributes().value("photo").toS tring());

QByteArray by(QByteArray::fromBase64(wBData1));
fil.write(by); // write into a file

/*************************/

Thanks

Askar