图片下载从SQLServer数据库

这篇博客介绍了如何从SQLServer数据库中下载图片。通过使用SqlCommand查询图片数据,然后利用FileStream和BinaryWriter将图片字节流写入本地文件,实现了图片的下载功能。用户可以选择保存图片的格式和路径。
摘要由CSDN通过智能技术生成

  String clid = this.dataGridView3.CurrentRow.Cells["clid"].Value.ToString();
            String cllx = this.dataGridView3.CurrentRow.Cells["cllx"].Value.ToString();
            SqlCommand cmd = new SqlCommand("select climg from lab_fwgl_zmcl where clid='" + clid + "'", alluse.Class1.conn1);
            FileStream fs;
            BinaryWriter bw;
            //设定允许读取到缓冲区的最大长度
            int buffersize = 100;
            //要将字节流读入的缓冲区
            byte[] outbyte = new byte[buffersize];
            //用于记录已经读取的字节数
            long reval;
            //字段中的索引,从这里开始读取操作
            long startIndex;
            //FileStream对象将封装的文件的相对路径或绝对路径
            //string filePath = Application.StartupPath + "//temp//证明资料" + zlid + zlid;// @"C:/wordData.doc";
            SaveFileDialog sfd

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值