注册 登录
编程论坛 SQL Server论坛

如何把存储在表中一个字段中的照片显示出来?

xtwhg6666 发布于 2011-01-04 15:39, 591 次点击
如何把存储在表中一个字段中的照片显示出来?
2 回复
#2
qingshuiliu2011-01-31 10:43
在什么地方显示?
如果是在页面上显示的话,给你一段参考代码。
            byte[] photo = table.FileContent; //FileContent是保存照片的数据库字段
            string strPath = "~/photos/" + table.ID + ".JPG"; //路径
            string strPhotoPath = page.Server.MapPath(strPath); //获取绝对路径
            BinaryWriter bw = new BinaryWriter(File.Open(strPhotoPath, FileMode.OpenOrCreate)); //获取一个 实例
            bw.Write(photo);
            bw.Close();
            image.ImageUrl = strPath;

#3
baoyuwang1982011-02-06 19:48
可以把该图片的路经存在数据库中,然后通过读出路径To src
1