2011-07-04 130 views

回答

1

我會愛你的Gooogle企業比索要幫助,如果你發現很難理解反正檢查下面的文章幫助第一次搜索你實現你的任務

C# Save and Load Image from Database

+0

在這篇文章中圖像字段設置爲BLOB類型,但我沒有任何類型作爲我的數據庫中的BLOB類型。(.mdf) –

+0

@saurabh goyal - 檢查此文章:http://www.fryan0911.com/2009 /05/c-how-to-save-and-retrieve-image-to-ms.html其中有使用圖像數據類型 –

0

您可以嘗試這樣的事:

if (this.fileUploader.PostedFile == null || 
    this.fileUploader.PostedFile.ContentLength < 1) 
{ 
    this.LabelError.Text = this.GetGlobalResourceObject("Messages", "NoFileToUpload") 
           .ToString(); 
    return; 
} 

MyTableWithImageField i = new MyTableWithImageField(); 

i.ImageData = this.fileUploader.FileBytes; 

command.CommandText = @"InsertMyTableWithImageField"; 
command.CommandType = CommandType.StoredProcedure; 

command.Parameters.AddWithValue("@ImageData", i.ImageData); 

您可能也想從MSDN檢查:Uploading Files in ASP.NET 2.0

相關問題