EDN Admin
Well-known member
I am not sure what to try at this point. My goal is to use C# to recreate an image previously saved into SQL server at varbinary(MAX). For starters I am not sure if the stored images are valid. Assuming that they are, what would I need to look at when I get the following error when I try to create the image from stream. Parameter is not valid.
I connect to the SQL server. I read the varbinary field into a new memorystream.
<font color="#2b91af" size=2><font color="#2b91af" size=2>
MemoryStream</font></font><font size=2> ms = </font><font color="#0000ff" size=2><font color="#0000ff" size=2>new</font></font> <font color="#2b91af" size=2><font color="#2b91af" size=2>MemoryStream</font></font><font size=2>((</font><font color="#0000ff" size=2><font color="#0000ff" size=2>byte</font></font><font size=2>[])sqlImageReader[</font><font color="#a31515" size=2><font color="#a31515" size=2>"anImage"</font></font><font size=2>]); </font>This is the point where I encounter the error.
<font size=2>
System.Drawing.</font><font color="#2b91af" size=2><font color="#2b91af" size=2>Image</font></font><font size=2> imgImage = System.Drawing.</font><font color="#2b91af" size=2><font color="#2b91af" size=2>Image</font></font><font size=2>.FromStream(ms); </font>
View the full article
I connect to the SQL server. I read the varbinary field into a new memorystream.
<font color="#2b91af" size=2><font color="#2b91af" size=2>
MemoryStream</font></font><font size=2> ms = </font><font color="#0000ff" size=2><font color="#0000ff" size=2>new</font></font> <font color="#2b91af" size=2><font color="#2b91af" size=2>MemoryStream</font></font><font size=2>((</font><font color="#0000ff" size=2><font color="#0000ff" size=2>byte</font></font><font size=2>[])sqlImageReader[</font><font color="#a31515" size=2><font color="#a31515" size=2>"anImage"</font></font><font size=2>]); </font>This is the point where I encounter the error.
<font size=2>
System.Drawing.</font><font color="#2b91af" size=2><font color="#2b91af" size=2>Image</font></font><font size=2> imgImage = System.Drawing.</font><font color="#2b91af" size=2><font color="#2b91af" size=2>Image</font></font><font size=2>.FromStream(ms); </font>
View the full article