[英]Difference between Normal Image Insert and insert as Bulk BLOB
我有帶有表圖像的sql
數據庫,在該表中有2 Columns
ID
(標識),DisplayImage(圖像)。 我寫的第一行有2行
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,則它會給出無效的參數錯誤,但是如果我使用ID 2,它將正常運行。 那么區別是什么呢?? 以及我必須進行什么更改才能運行正常的插入圖像。我不想在插入語句中使用AS BLOB
insert 1語句插入字符串'Libraries \\ Pictures \\ Lotus.jpg'而不是圖像。 那就是為什么當您訪問它時會給出無效的參數錯誤。
如果必須存儲圖像,則必須使用BLOB
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.