<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[How to store binary data to SQL database as nvarbinary?]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">I need to store some files to SQL Server database, such as word, excel and pictures. I tried to read binary file data to a QByteArray, but the file contains lots of '\0' byte and this is regarded as the end of the array, so when the QByteArray object can only store a small part of the file, not all the data.<br />
I think I should first read file into a buffer and then insert the buffer's content to database, but i don't know how to do this use a QSqlQuery, can anybody help me, thanks!</p>
<p dir="auto">Thanks!</p>
]]></description><link>https://forum.qt.io/topic/33529/how-to-store-binary-data-to-sql-database-as-nvarbinary</link><generator>RSS for Node</generator><lastBuildDate>Thu, 18 Jun 2026 01:02:55 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/33529.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 25 Oct 2013 15:26:20 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to store binary data to SQL database as nvarbinary? on Thu, 14 Nov 2013 21:16:17 GMT]]></title><description><![CDATA[<p dir="auto">IIRC, QByteArray handles \0 like any other char, you can verify the size of the array once loaded</p>
]]></description><link>https://forum.qt.io/post/204095</link><guid isPermaLink="true">https://forum.qt.io/post/204095</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Thu, 14 Nov 2013 21:16:17 GMT</pubDate></item><item><title><![CDATA[Reply to How to store binary data to SQL database as nvarbinary? on Sat, 26 Oct 2013 01:47:06 GMT]]></title><description><![CDATA[<p dir="auto">I saw this function:<br />
ByteArray QByteArray::fromBase64(const QByteArray &amp; base64);</p>
<p dir="auto">This needs another QByteArray, and the question still exsits. The input QByteArray will be truncated, and only the part before the first '\0' will be copied to the new QByteArray.</p>
<p dir="auto">[quote author="SGaist" date="1382728116"]Hi,</p>
<p dir="auto">You can use base64 encoding for you binary data</p>
<p dir="auto">Hope it helps[/quote]</p>
]]></description><link>https://forum.qt.io/post/201944</link><guid isPermaLink="true">https://forum.qt.io/post/201944</guid><dc:creator><![CDATA[qingyun]]></dc:creator><pubDate>Sat, 26 Oct 2013 01:47:06 GMT</pubDate></item><item><title><![CDATA[Reply to How to store binary data to SQL database as nvarbinary? on Sat, 26 Oct 2013 01:41:56 GMT]]></title><description><![CDATA[<p dir="auto">Can you tell a lit more please, or giev me a link about this?<br />
I should still use QByteArray to do this, or use other method?</p>
<p dir="auto">[quote author="SGaist" date="1382728116"]Hi,</p>
<p dir="auto">You can use base64 encoding for you binary data</p>
<p dir="auto">Hope it helps[/quote]</p>
]]></description><link>https://forum.qt.io/post/201942</link><guid isPermaLink="true">https://forum.qt.io/post/201942</guid><dc:creator><![CDATA[qingyun]]></dc:creator><pubDate>Sat, 26 Oct 2013 01:41:56 GMT</pubDate></item><item><title><![CDATA[Reply to How to store binary data to SQL database as nvarbinary? on Fri, 25 Oct 2013 19:08:36 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">You can use base64 encoding for you binary data</p>
<p dir="auto">Hope it helps</p>
]]></description><link>https://forum.qt.io/post/201920</link><guid isPermaLink="true">https://forum.qt.io/post/201920</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Fri, 25 Oct 2013 19:08:36 GMT</pubDate></item></channel></rss>