Load image in PictureBox of Winform C# from SQL Server 2008 r2 -
i using sql server 2008 r2 database , winform c# 2010. in table able save image winform. when tried view image, there error showing.
table is
create table [dbo].[tbl_image]( [id] [char](7) not null, [photo] [image] null)
and data in table
i trying show photo in piturebox using bellow code
sqlconnection con; sqldataadapter adapter; dataset ds; int rno = 0; memorystream ms; byte[] photo_aray; con = new sqlconnection("user id=sa;password=123;database=dbtest"); adapter = new sqldataadapter("select [id],[photo] [tbl_image] [id]='0321253'", con); adapter.missingschemaaction = missingschemaaction.addwithkey; ds = new dataset(); adapter.fill(ds, "student"); if (ds.tables[0].rows.count > 0) { picturebox2.image = null; if (ds.tables[0].rows[rno][4] != system.dbnull.value) { photo_aray = (byte[])ds.tables[0].rows[rno][1]; memorystream ms = new memorystream(photo_aray); picturebox2.image = image.fromstream(ms); } } else messagebox.show("no records");
but giving error "parameter not valid." in line picturebox2.image = image.fromstream(ms)
how can solve this?