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);  

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

4 Years
Discussion Span
Last Post by LastMitch
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.