将图像存储在sqlserver数据库中,并使用c#在asp的gridview中检索图像 [英] storing a image in sqlserver database and retrive it in gridview in asp using c#

查看:102
本文介绍了将图像存储在sqlserver数据库中,并使用c#在asp的gridview中检索图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将图像和文本数据存储在sqlserver数据库中,并使用c#.... plz在asp的gridview中检索和显示输出,帮助我找出解决方案

how i can store an image and text data in sqlserver database and retrive it and display the output in a gridview in asp using c#....plz help me to find out the solution

推荐答案

1.将图像从文件strean转换为字节数组.

2.在数据库中声明图像类型的字段

3.将字节数组写入数据库

4.要显示数据库中的图像,请将数据库中的字节数组转换为流,并将其保存在文件中并提供文件的路径.
1.Convert the image from file strean to byte array.

2.Declare the field in Database of type image

3. write the byte array to database

4. To display image from database, convert the byte array from database to stream and keep it in a file and give the path of the file.


参考:
http://www.aspdotnet-suresh.com/2011/01/how-to-insert-images-into-database-and.html [
refer:
http://www.aspdotnet-suresh.com/2011/01/how-to-insert-images-into-database-and.html[^]


您需要决定如何保存图像.我的意思是您是否要保存图像的路径?或想以二进制格式将整个图像保存为SQL.

我个人认为将图像保存在文件系统中,仅将路径保存在DB buit中,这取决于您的要求.如果您的数据量较少,那么也可以使用DB.请参考下面的链接

点击此处
You need to decide how do you want to save image. I mean whether you want to save the path of image? or want to save the whole image in SQL in binary format.

I personally feel to save the image in filesystem and save the path only in DB buit it depends on your requirement. If you have less amount of data then you can go for DB as well. Please refer the link below

Click here


这篇关于将图像存储在sqlserver数据库中,并使用c#在asp的gridview中检索图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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