I have sql database with table Images, in that table there are 2 Columns ID (identity), DisplayImage (image). Table has 2 rows for first row i have written

insert into Image values(1,'Libraries\Pictures\Lotus.jpg') and 2nd row as

INSERT INTO [dbo].[Image] ([Id],Images) SELECT 2, (select * FROM OPENROWSET(BULK 'C:\Users\Public\Pictures\Sample Pictures\Tulips.jpg', SINGLE_BLOB) AS BLOB)

Here is the code for reading the image

WebClient instanceHTTP = new WebClient();
Uri MyUri = new Uri("http://localhost:52293/WebSite/ImageHandler.ashx?ImageId=" + TextBox5.Text); //TextBox5.Text for id i.e 1 or 2 
Stream returnValue;
returnValue = instanceHTTP.OpenRead(MyUri);
System.Drawing.Image MyImage = System.Drawing.Image.FromStream(returnValue); // Error if id=1 used i.e normal insert 
bytearray = imageToByteArray(MyImage);  
MyImage.Dispose(); 

if i use id 1 that is normal insert than it gives error that invalid Parmeter but if i use id 2 it runs properly. So what is the difference?? and what changes i have to make in order to runn normal insert image.. I dont want to use AS BLOB in insert statement

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.