Hi all, I am trying to read a value from my database which stores an image. Now I inserted a binary value directly using the following SQL statement:
insert into [test] values <br />
('13780787113102610000137372688200016000168600031243255970001115827166017420628233000410365776500177143112529750003299728277001223800128132002500001282320011748002349600581520023112156186816000110173686584567912514717375131812019822131971778822132972113217282664217240136195162197367648451051461932101626913954193343466313014381781333314277131321361362541711271351572031892391357301982221572232431561232381871401361216584244135769831617253125211535926119154169143233179655253492161922227971208243119755895151301371032285622364191318812059150901913612322110157121217151214231157526317437191147133849372114104486187791398210523229244245641102232071001626023476986624373251882535647155141661621291661158619838178914510824019825317284219101237203173142104111923211488201054017321411016616511614979549673164161180294186156210934191768915011921617318611320513217745251201711771626217133971194616381082419232158147106201197243201010252382218426121521941813362515252427888186111160839619413481165185174169810819240285380191501315639242656312111213123881934314117205190188155249247207205174310913095411421152115512351970000736978681746696130')
When I view my table it shows the value <binary data>. I am using the following code in my app to try displaying the image:
string Sql = "select col1 from [test]";<br />
SqlDataAdapter da = new SqlDataAdapter(Sql, Con);<br />
DataSet ds = new DataSet();<br />
da.Fill(ds);<br />
Con.Open();<br />
<br />
foreach (DataRow Dr in ds.Tables[0].Rows)<br />
{<br />
byte[] Img = (byte[])Dr["Col1"];<br />
System.IO.MemoryStream MS = new System.IO.MemoryStream(Img);<br />
Image myimg = Image.FromStream(MS);<br />
pictureBox1.Image = myimg;<br />
}
I get the error stating
Parameter is not valid .
Any ideas why this ain't working for me?
When I use the SQLCommand object and a parameter to it, it displays the image fine...