如何将图像与其他值一起插入数据库. [英] How to insert image into database along with other values.

查看:167
本文介绍了如何将图像与其他值一起插入数据库.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个表单,其中有各种值,例如名称,地址,出生日期等.还允许用户在图片框中选择图像.
我想将这些值与Image一起插入数据库的适当列中.
感谢所有帮助.

I have created a form in which there are various values such as Name, Address, Date of Birth etc. The user is also allowed to select an image in a picture box.
I want to insert these values along with the Image into database in appropriate columns.
Any help is appreciated

推荐答案

将图像序列化为字节数组(由您决定如何执行此操作).然后将其插入varbinary(max)类型或image的列中.这些数据类型名称有点让人误解....数据类型图像"实际上表示字节数组(与varbinary一样).从数据库中获取图像时,需要将其反序列化以再次将其用作图像.
Serialize the image as a byte array (up to you how you want to do that). Then insert it into a column of type varbinary(max) or image. Those data type names are a bit misleading.... the data type "image" actually means byte array (as does varbinary). When you get the image from the database, you''ll need to deserialize it to use it as an image again.


您可以通过将图像转换为字节并将其存储到数据库中来将图像存储到数据库中.列中的字节数

阅读此文章以供参考
You can store images into database by converting image into bytes and storing these bytes in column

read this article for reference


这篇关于如何将图像与其他值一起插入数据库.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆