如何从数据库中检索二进制格式的图像 [英] how to retrieve binary formated image from database

查看:84
本文介绍了如何从数据库中检索二进制格式的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在使用asp.net 4.0后端是sqlserver2008,并且我将图像以二进制格式存储在数据库表中.现在我想使用wcf和linq to sql概念来检索它.
怎么做.谁能帮我解决我的需求.


i am using asp.net 4.0 backend is sqlserver2008, and i stored image in the data base table as binary format. now i want to retrieve it using wcf and linq to sql concept.
how to do it. can anyone help me in my requirement.

推荐答案

语录:

我认为你用过
foreach(在dt.rows中的DataRow dr)
{
如果(dr!= null)
{
byte [] byt =(byte [])dr [2];
字符串str;
System.Text.ASCIIEncoding enc =新的System.Text.ASCIIEncoding();
str = enc.GetString(byt);
dr [4] = str;
}
}
用于将图像另存为二进制文件.
因此您可以使用相反的方式来获取图像.
System.Text.ASCIIEncoding编码=新的System.Text.ASCIIEncoding();
abl.packageDescription = encoding.GetBytes(Editor1.Content);

i think you have used
foreach (DataRow dr in dt.Rows)
{
if (dr != null)
{
byte[] byt = (byte[])dr[2];
string str;
System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
str = enc.GetString(byt);
dr[4] = str;
}
}
for saving the image as binary.
so you can use the opposite way to get the image.
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
abl.packageDescription = encoding.GetBytes(Editor1.Content);


查看此链接
可能会帮助您

http://debugmode .net/2010/05/10/inserting-and-retrieving-image-using-linq-to-sql-from-asp-net-application/ [
See this link
May help you

http://debugmode.net/2010/05/10/inserting-and-retrieving-image-using-linq-to-sql-from-asp-net-application/[^]


这篇关于如何从数据库中检索二进制格式的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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