Database varbinary(MAX) to RichText Box
<p>Here i Saved .Doc files in Database and i used varbinary(MAX) Datatype. Now I want to bind the  varbinary(MAX) field to Richtext box, Here i am used bellow code to  Read binary format data to string type.</p>

<pre><code>string Query = "Select Name, ContentType, DocFileText from &lt;TableNAme&gt; where Id=5";
            SqlCommand cmd = new SqlCommand(Query, con);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            con.Open();
            SqlDataReader sqlRead = cmd.ExecuteReader(); 
            while (sqlRead.Read())
            {      
           byte[] fileData = ((byte[])sqlRead["DocFileText"]);
            Richtextbox1.Text = Encoding.ASCII.GetString(fileData);            
              }
</code></pre>

<p>but the data should be in unreadable format like :</p>

<pre><code>PK!0?(r?[Content_Types].xml ?(??T?n?0?W??D?V??????[??0??z??l?I?Q?B? \"%?????????l ?w%?=???^i7+???%?g&amp;??0?A?6?l4??L60#????S ????X??&amp;??V$z?3??3 ??????%p)O5?????5}?:?`?e????V?DFK??)_:?K%?)?l??\?!??U?'?v?7?&amp;j?X??*,??+W^.,???????W????k??D?????X?????&gt;??N!??FZ??&amp;0m??ly??)?q?9??d}???@??????????R??/??s???*&amp;:t??g?????????8Y?O?[??&amp;V0}?X????????&gt;?#??;?F?io.????PK!???N_rels/.rels ?(????JA???a?}7? "???H?w"????w?????? ?P?^????O?????;?&lt;?aY????`G?kxm??PY?[??g G??ino?/"f3??\???T??I S??????????W????Y ig?@??X6_?]7~ f?????ao?.b*lI?r?j)?,l0?%??b? 6?i???D?_???, ? ???|u?Z^t??y??;!Y,}{?C??/h&gt;??PK!??? ?word/_rels/document.xml.rels ?(????J?0?????n????l?????v???$?j?????..??K`?????0??L'????YI?@[????????? D mK?9? ?Ooovo?i?G?i? ?? Q?,e(4:D?G?7??F????.&gt;u?r?[???^x?C???{??s??????_\q4h?J?H?????FRpR"?ya?* ?p???d?x{49z??Dp?? ?kB?Nc)?3Ybx\??r?2?w3?????&amp;?7??Vr&amp;?@??oK??PK!??????2word/document.xml?Y[O?0~????r????BiCH????.???????_?s?84?-a-#??;&gt;??|&gt;N..??P?S.?u???5{l??}???{??5!I??@???Z#sl?}?????M??iuK??B?? ???]????=???O?F??o????ba?)??Nw8,Ht'pn6??P7??p)N?*97?tl???#'L???????se~??;?Y??;???}?K?????v???M??????K???j?&gt;U????+g?^U|?????C N???M?~%????a???????H??m?/?&amp;?M_?i=??????VQN?0?J?@??l??J?|!U??4[]S%??7?$?i7:?bB???Nl??{uH5""3%hA?:?g?????n???:????@??xi%?z_vZ?*U?m??u??2?Jq??'?3?h???1Q?, ??????'??;??g?? ?Ev?????0$??`XmtGr??!?e_?}v??#??????????dT?h+?j-,A?%#???6? ??w?????|UOQ4????E?ga?V???#?????w2?|????????~????WH??X????t?^^???O????????lK?=?K????? ?93?.????????????ev?j??????|?4?y0??e?????=FV ??^?r?Zh9#??_vvsN3?r????????\m?]??1Y n4?X/2?.??`?%O?a????A??l??????N?d???????PK!?????Pword/theme/theme1.xml?YOo?6??w toc'vu????-M?n?i???P?@?I}?????a??m?a[????4?:l???GR??X^?6???&gt;$?????????!)O?^?r?C$?y@?????/?yH*??????)?????????UDb?`}"?q???J?????X^?)I`n?E???p)???li?V[]?1M???G?M?Ge???D?????3Vq%'#q??????$?8??K?????)f?w9:????? x}r?x????w???r?:\TZaG?*?y8I?j?bR??c|X??????I u3KG?nD1?NIB?s??? ??R??u???K&gt;V?.EL+M2?#'?f??i~?V??vl?{u8??z??H? ?*????:?(W???? ~??J??T?e\O*?tHG??HY???}KN??P?*???????T???9/#??A7?qZ??$*c????qU??n??w?N??%??O??i??4=3??P?? ????1?P?m\\9?????????M???2a?D?]?;Yt?\????[x??????]?}Wr??|?]??g-??? eW? ?)6-r??CS?j?? i?d ?D??A???IqbJ#x????6k???#??A?Sh???&amp;??t(Q?%??p%m??&amp;]?caSl=?X???????\P?1?Mh?9?M???V?dDA??aV?B??[??fJ???P|8???A?V^???f ?H??n???-??"??d&gt;?z???n????? ?????&gt;??b???&amp;?????2??v????Ky?????D:????,AGm??\nz??i?????.u??YC?6?OMf??3o?r??$??5?????NH?T[XF64?T,?????M0?E)`#?5?XY?`???;??%?1?U???m;???R&gt;QD????D?cp?U?'??&amp;LE?/p???m????%]?????8fi??r?S4?d7y\?`?J??n??????I?R???3U?~7+?????#??m?q?BiD??????????i*?L6?9??m?Y&amp;?????i???HE??=(K&amp;?N!V??.K?e?LD????{D ????vE???de??N????e?(?MN9??R??6????&amp;3(??a????/D??U?z???)???D????_??k??wXXub?????(?9??8?????????????&lt;4??u?&gt;?p?? ???F????
</code></pre>

<p>Here i used</p>

<pre><code> Encoding.UTF8.GetString(fileData);
            Encoding.Unicode.GetString(fileData);
</code></pre>

<p>but these are also not working.
How can i read Doc file from database to richtextbox ?</p>

<p>And My Uploaded Code is:</p>

<pre><code> string filename = Path.GetFileName(FileUpload1.PostedFile.FileName);
        Stream str = FileUpload1.PostedFile.InputStream;
        BinaryReader br = new BinaryReader(str);
        Byte[] size = br.ReadBytes((int) str.Length);
        using (SqlConnection con = new SqlConnection(Connstring))
        {
            using (SqlCommand cmd = new SqlCommand())
            {
                cmd.CommandText = "insert into Gtrans(Name, ContentType, DocFileText) values(@Name, @ContentType, @DocFileText)";
                cmd.Parameters.AddWithValue("@Name", filename);
                cmd.Parameters.AddWithValue("@ContentType", "application/word");
                cmd.Parameters.AddWithValue("@DocFileText", size);
                cmd.Connection = con;
                con.Open();
                cmd.ExecuteNonQuery();
                con.Close();

            }
        }
</code></pre>