简体   繁体   中英

How to store an image into database

如何使用openfile对话框和图片框并上传图像并将其存储到SQL Server

If you g0ogled c# store image in sql , the first 2 results would have been

Store or save images in SQL Server database using C#

Store or Save images in SQL Server

You need to keep field datatype as varbinary(Max) in the database table. then convert image into byte array. then pass this byte array as parameter respect to your varbinary field. it will be saved in your database. while retrieving, get value from database as byte array the convert it into Image object. hope this sequence helps you. or more code example you can find here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM