2011-07-04 43 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