<asp:Image ImageUrl="Image.aspx?id=123" runat=server />and see how to write Image.aspx inRetrieving Images from SqlServer in ASP .NET
http://authors.aspalliance.com/das/readimage.aspx

解决方案 »

  1.   

    你好,还要麻烦你!这是我的上传程序!
    private void Button1_Click(object sender, System.EventArgs e)
    {
    HttpPostedFile UpFile = UP_FILE.PostedFile;  //HttpPostedFile对象,用于读取图象文件属性 
    FileLength = UpFile.ContentLength;     //记录文件长度  
    try 

    if (FileLength == 0) 
    {   //文件长度为零时 
    txtMessage.Text = "<b>请你选择你要上传的文件</b>";  

    else 

    Byte[] FileByteArray = new Byte[FileLength];   //图象文件临时储存Byte数组 
    Stream StreamObject = UpFile.InputStream;      //建立数据流对像 
    //读取图象文件数据,FileByteArray为数据储存体,0为数据指针位置、FileLnegth为数据长度 
    StreamObject.Read(FileByteArray,0,FileLength); 
    String cmdInsert = "INSERT INTO ImageStore (ImageData, ImageContentType, ImageDescription, ImageSize) VALUES (@Image, @ContentType, @ImageDescription, @ImageSize)"; 
    SqlCommand CmdObj = new SqlCommand(cmdInsert,sqlConnection1); 
    CmdObj.Parameters.Add("@Image",SqlDbType.Binary, FileLength).Value = FileByteArray; 
    CmdObj.Parameters.Add("@ContentType", SqlDbType.VarChar,50).Value = UpFile.ContentType;  //记录文件类型 
    //把其它单表数据记录上传 
    CmdObj.Parameters.Add("@ImageDescription", SqlDbType.VarChar,200).Value = txtDescription.Text; 
    //记录文件长度,读取时使用 
    CmdObj.Parameters.Add("@ImageSize", SqlDbType.BigInt,8).Value = UpFile.ContentLength; 
    sqlConnection1.Open(); 
    CmdObj.ExecuteNonQuery();  
    sqlConnection1.Close(); 
    txtMessage.Text = "<p><b>OK!你已经成功上传你的图片</b>";//提示上传成功 


    catch (Exception ex) 

    txtMessage.Text = ex.Message.ToString(); 
    }
    }
    我想用c#在asp.net中,用Image服务器控件显示我在数据库存储的图片!谢谢!!
      

  2.   

    I already showed you a link where you can find an example, or see a C# example
    Uploading and retrieving images from SQL Server
    http://www.dotnetbips.com/displayarticle.aspx?id=60