如何在SQL中存储图像 [英] how to store image in sql

查看:82
本文介绍了如何在SQL中存储图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个信息系统,我必须存储这些人的图像,告诉我该怎么做.我试图直接在sql server中插入图像,但是之后我无法检索它们.我该怎么办

I am developing a information system and I have to store the images of the persons, tell me how should I do that. I have tried to insert the images in sql server directly but after that I''m not able to retrieve them. What should I do

推荐答案

我建​​议不要将图像存储在sql-server中,而是将图像存储在硬盘驱动器上的路径(如果需要)将映像复制到网络共享)

将图像插入数据库只会使其增长非常快.
I would suggest not to store the image in the sql-server but rather the path where the image is stored on the hard drive (if needed copy the image to a network share)

Inserting images into your database will only cause it to grow extremely fast.


您好,

检查以下URL:

http://aspalliance.com/articleViewer.aspx?aId=138&pId= [ ^ ]

希望您能解决您的问题.

谢谢
Mehul Thakkar
Hi,

Check the below URL:

http://aspalliance.com/articleViewer.aspx?aId=138&pId=[^]

Hope you will get the solution of your problem.

Thanks
Mehul Thakkar


--image_data is an IMAGE field           
SqlCommand cmd = new SqlCommand("SELECT image_data FROM GRAPHIC WHERE ID = 5", cn);

--Load into Byte Array
byte[] b = (byte[])cmd.ExecuteScalar();
MemoryStream ms = new MemoryStream(b);

--Load stream into an image object
Image img = Image.FromStream(ms);
pictureBox1.Image = img;


这篇关于如何在SQL中存储图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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