从SQL Server检索图像并将其存储在本地驱动器中 [英] Retriving Images from sql server and store it in local drive

查看:69
本文介绍了从SQL Server检索图像并将其存储在本地驱动器中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友

我正在将朋友图像插入我的sql数据库中,现在我想从数据库中检索图像并将其保存到本地驱动器中,但是我无法处理,请帮助我.

Hi friends

i am inserting my friends image in my sql database and now i want to retrieve image from database base and save it to my local drive but i am unable to o it please help me.

try
            {
                String sql = "Select name, Image from ImageTest";
                DataTable dt = new DataTable();
                _Connection.FillTable(ref dt, sql);
                Image img = null;
                for (int i = 0; i <= dt.Rows.Count - 1; i++)
                {
                    string TempPath;
                    TempPath = System.IO.Path.GetTempPath() + "\\myImage.jpeg";
                    img = _Connection.RetriveImageFromDB(dt.Rows[i][1]);
                    img.Save(System.IO.Path.GetTempPath() + "\\myImage.jpeg", ImageFormat.Jpeg);                  
                  
                }
            }

            catch { }


我的代码无法正常工作,并且出现错误"GDI +中发生一般错误"


my code is not working and i get a error "A generic error occurred in GDI+"

推荐答案

您是否尝试过使用数据读取器,将数据临时存储在一般对象中然后将其转换为Image对象?将其保存到固定的目的地(C:/)?
只是尝试.
Have you tried using a datareader, temporary storing the data in a general object and then casting it into an Image object? saving it to a fixed destination (C:/)?
just to try.


这篇关于从SQL Server检索图像并将其存储在本地驱动器中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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