linq to sql 上传,显示图片
2015-12-14 16:29
453 查看
private void button1_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { tbPath.Text = ofd.FileName; } } private void button2_Click(object sender, EventArgs e) { ShiJiYuanDataContext cxt = new ShiJiYuanDataContext(); OtherImg otherImg = new OtherImg(); FileStream fs = new FileStream(tbPath.Text, FileMode.Open, FileAccess.Read); byte[] bytes = new byte[fs.Length]; fs.Read(bytes, 0, (int)fs.Length); otherImg.img = bytes; cxt.OtherImgs.InsertOnSubmit(otherImg); cxt.SubmitChanges(); MemoryStream ms = new MemoryStream(bytes); Image img = Image.FromStream(ms); this.pictureBox1.Image = img; } private void button3_Click(object sender, EventArgs e) { ShiJiYuanDataContext cxt = new ShiJiYuanDataContext(); OtherImg otherImg = cxt.OtherImgs.SingleOrDefault(p => p.id.ToString() == tbId.Text); byte[] bytes = new byte[otherImg.img.Length]; bytes = otherImg.img; MemoryStream ms = new MemoryStream(bytes); Image img = Image.FromStream(ms); this.pictureBox1.Image = img; }
相关文章推荐
- MySQL存储过程及触发器
- sqlldr常规应用 (总结篇)
- Navicat 链接虚拟机MySQL失败(GRANT ALL PRIVILEGES)
- sql server case when 判断为空
- oracle数据库rman备份计划及恢复
- SqlServer中wait type类型及说明
- Redis在windows环境下的部署
- Liunx 导入MySQL数据库
- Oracle 收集统计信息11g和12C在差异
- oracle 表锁的问题
- Redis缓存异常的容错实现方法( .net)
- 用单例连接oracle数据库
- mysql时间加减
- 用hibernate连接mysql插入数据出错ConstraintViolationException
- oracle批量转库工作,比较快捷的方式
- MongoDB 难点
- PROC简单的用例--VC连接ORACLE
- MySQL性能优化的最佳20+条经验
- NoSQL 45分钟教程
- Linux中Oracle环境变量配制