0
我有sql
數據庫與表圖像,在該表中有2 Columns
ID
(identity),DisplayImage(圖像)。表有兩行對第一行i已經寫正常圖像插入和插入之間的區別作爲批量BLOB
insert into Image values(1,'Libraries\Pictures\Lotus.jpg')
和第二行作爲
INSERT INTO [dbo].[Image] ([Id],Images)
SELECT 2,
(select * FROM OPENROWSET(BULK 'C:\Users\Public\Pictures\Sample Pictures\Tulips.jpg', SINGLE_BLOB) AS BLOB)
下面是用於讀取圖像
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();
如果我使用ID 1是代碼正常插入比它給出錯誤,無效Parmeter 但如果我使用ID 2它正常運行。 那麼有什麼區別?以及爲了運行正常的插入圖像而必須做出的更改。我不想在插入語句中使用AS BLOB