ASP.NET store Image in SQL and retrieve for Asp:Image

前端 未结 7 842
挽巷
挽巷 2020-12-01 17:41

I am looking to fileupload a picture jpeg,gif,etc into an SQL database on an updateprofilepicture page. Then on the profile page, I want to retrieve the image from an sql da

7条回答
  •  栀梦
    栀梦 (楼主)
    2020-12-01 18:01

    If you're using SQL 2005 or greater you should not use the data type Image because it's now deprecated. Instead you want to use the new Varbinary(MAX) type if possible. Once you have it stored all you need to do is retrieve it via ADO.Net call and cast the cell value into type Byte[] and then call Response.BinaryWrite like in ScarletGarden's example above.

提交回复
热议问题