Adding an image file to a database with C# and ASP.NET
How can I add an image file (for example, JPEG, PNG开发者_JAVA百科, GIF ...) to a database with C# and ASP.NET?
I'm just working on the project. And now I need your help.
The best way is to simply store the path of the image in the database. Answered fully here and here
If you want the actual image in the DB, then you will have to perform what is referred to as "Blobbing". You will need to convert the image into a Byte Array(Byte[]) and then store the array in the database. The field in the database is going to need to be appropriate for storing a Blob.
Then when you load the image from the DB (to display it), you will have to convert it back into an image. It would probably be useful to store the image type along with the image data so that you know what format to convert that image data into.
Try this
http://www.aspsnippets.com/Articles/Display-Images-in-GridView-Control-using-the-path-stored-in-SQL-Server-database.aspx
精彩评论