<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>SQL Server, SQL Server Express, and SqlDataSource Control</title><link>http://forums.asp.net/54.aspx</link><description>All about SQL Server, SQL Server Express, MSDE, and the SqlDataSource control.</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Re: My byte[] becomes empty when inserted to database</title><link>http://forums.asp.net/thread/3275553.aspx</link><pubDate>Sun, 05 Jul 2009 18:09:04 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3275553</guid><dc:creator>Naom</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3275553.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=54&amp;PostID=3275553</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;In your original code&lt;/p&gt;
&lt;p&gt;cmd.Parameters[&lt;span&gt;&amp;quot;@&amp;nbsp;bindata&amp;quot;&lt;/span&gt;&lt;span&gt;].Value&amp;nbsp;=&amp;nbsp;bindata;&amp;nbsp;&lt;/span&gt;&lt;span&gt;//&amp;nbsp;bindata&amp;nbsp;is&amp;nbsp;a&amp;nbsp;byte[]&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;// remove a space here&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;</description></item><item><title>Re: My byte[] becomes empty when inserted to database</title><link>http://forums.asp.net/thread/3275531.aspx</link><pubDate>Sun, 05 Jul 2009 17:23:09 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3275531</guid><dc:creator>RickNZ</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3275531.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=54&amp;PostID=3275531</wfw:commentRss><description>&lt;p&gt;Try removing the space between the @ and bindata, on the line where you set its value.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: My byte[] becomes empty when inserted to database</title><link>http://forums.asp.net/thread/3275298.aspx</link><pubDate>Sun, 05 Jul 2009 11:13:45 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3275298</guid><dc:creator>Zcumbag</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3275298.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=54&amp;PostID=3275298</wfw:commentRss><description>&lt;p&gt;The column is a varbinary(8000) in my sql server 2008.&lt;/p&gt;&lt;p&gt;My bindata[] gets its value like this:&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div style="position:absolute;left:-10000px;top:0px;width:1px;height:1px;overflow-x:hidden;overflow-y:hidden;" id="_mcePaste"&gt;BinaryFormatter bf = new BinaryFormatter();&lt;/div&gt;
&lt;div style="position:absolute;left:-10000px;top:0px;width:1px;height:1px;overflow-x:hidden;overflow-y:hidden;" id="_mcePaste"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;MemoryStream s = new MemoryStream();&lt;/div&gt;
&lt;div style="position:absolute;left:-10000px;top:0px;width:1px;height:1px;overflow-x:hidden;overflow-y:hidden;" id="_mcePaste"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;bf.Serialize(s, this);&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;pre name="code" class="c-sharp"&gt;BinaryFormatter bf = new BinaryFormatter();
MemoryStream s = new MemoryStream();
bf.Serialize(s, this); // &amp;quot;this&amp;quot; is a class 

bindata = s.ToArray();
// at this row I can see that the bindata contains lots of info
&lt;/pre&gt;&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: My byte[] becomes empty when inserted to database</title><link>http://forums.asp.net/thread/3275013.aspx</link><pubDate>Sun, 05 Jul 2009 00:10:05 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3275013</guid><dc:creator>Segundo</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3275013.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=54&amp;PostID=3275013</wfw:commentRss><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Please &lt;/p&gt;
&lt;p&gt;1.- which&amp;#39;s the data type of that column in your database table?&lt;/p&gt;
&lt;p&gt;2.- which&amp;#39;s&amp;nbsp;the data type you use&amp;nbsp;to save that data in your code-beside?&lt;/p&gt;
&lt;p&gt;Any doubt, post your comment.&lt;/p&gt;</description></item><item><title>My byte[] becomes empty when inserted to database</title><link>http://forums.asp.net/thread/3274983.aspx</link><pubDate>Sat, 04 Jul 2009 22:38:11 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3274983</guid><dc:creator>Zcumbag</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3274983.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=54&amp;PostID=3274983</wfw:commentRss><description>&lt;p&gt;Hello.&lt;/p&gt;&lt;p&gt;I have a procedure that (is supposed to) instert a byte[] into a varbinary-field in sql server.&lt;/p&gt;&lt;p&gt;Here&amp;#39;s the code:&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;pre name="code" class="c-sharp:nogutter:collapse"&gt;SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings[&amp;quot;MyConnectionString&amp;quot;].ConnectionString);
            SqlCommand cmd = new SqlCommand(&amp;quot;SP_InsertStuff&amp;quot;, conn);
            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.Add(&amp;quot;@Id&amp;quot;, SqlDbType.UniqueIdentifier);
            cmd.Parameters[&amp;quot;@Id&amp;quot;].Value = pId; // pId is a Guid

            cmd.Parameters.Add(&amp;quot;@datetime&amp;quot;, SqlDbType.DateTime);
            cmd.Parameters[&amp;quot;@datetime&amp;quot;].Value = datetime;

            cmd.Parameters.Add(&amp;quot;@bindata&amp;quot;, SqlDbType.VarBinary);
            cmd.Parameters[&amp;quot;@ bindata&amp;quot;].Value = bindata; // bindata is a byte[]

            try
            {
                conn.Open();
                cmd.ExecuteNonQuery();
                return true;
            }
            catch
            {
                return false;
            }
            finally
            {
                conn.Close();
            }&lt;/pre&gt;&lt;p&gt;&lt;br /&gt;When I put a breakpoint in the code I can clearly see that the bindata contains lots of information. Everything seems to be working nice. Except, when I retrieve the data, or just look in my table, the bindata-column is empty (or poosibly just 1 byte size).&lt;/p&gt;&lt;p&gt;Why is this? Am I doing something wrong?&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;/D&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;</description></item></channel></rss>