找回密码
 立即注册

QQ登录

只需一步,快速开始

wengMQ 悬赏达人认证
银牌会员   /  发表于:2022-12-6 12:27  /   查看:1271  /  回复:1
sql保存字段类型image

1、保存文件到数据库

FileInfo rptFile = new FileInfo("报表文件路径");
                byte[] byte_pub = null;
                using (FileStream Rpt2Stream = rptFile.OpenRead())
                {
                    byte_pub = new byte[Rpt2Stream.Length];
                    Rpt2Stream.Read(byte_pub, 0, byte_pub.Length);
                }

                SqlParameter[] pars = new SqlParameter[]{
                                new SqlParameter("@pbstream",SqlDbType.Image)
                            };
                pars[0].Value = byte_pub;


2、读取报表文件

MemoryStream ms_pub = new MemoryStream();
                        byte[] byte_pub = (byte[])(Jb.ds_Pub.Tables[0].Rows[0]["FPbStream"]);
                        ms_pub.Write(Jb.byte_pub, 0, Jb.byte_pub.Length);
                        ms_pub.Seek(0, SeekOrigin.Begin);


using (TextReader StreamTxtRead = new StreamReader(ms_pub))
                        {
                          PageReport  ViewPgReport = new PageReport(StreamTxtRead);
                            ARptView.LoadDocument(ViewPgReport.Document);

                        }

评分

参与人数 2金币 +1688 收起 理由
Bella.Yuan + 888 赞一个!
KearneyKang + 800 很给力!

查看全部评分

1 个回复

倒序浏览
Bella.YuanWyn认证
超级版主   /  发表于:2022-12-6 13:36:33
沙发
给大佬点赞
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部