| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 5502 人关注过本帖
标题:pictureBox1.Image = Image.FromStream(ms)出错(参数无效)
只看楼主 加入收藏
jack_xu2046
Rank: 2
等 级:论坛游民
帖 子:72
专家分:11
注 册:2008-10-1
结帖率:81.82%
收藏
已结贴  问题点数:18 回复次数:3 
pictureBox1.Image = Image.FromStream(ms)出错(参数无效)
            string sql = "select cid,img from PicTable order by cid";
            SqlCommand cmd = new SqlCommand(sql, con);
            SqlDataAdapter dataAdapter = new SqlDataAdapter(cmd);
            DataSet dataSet = new DataSet();
            dataAdapter.Fill( dataSet , "BLOBTEST");
            int c = dataSet.Tables["BLOBTEST"].Rows.Count;
            try
            {
                if (c > 0)
                {
                    byte[] mybyte = new byte[0];
                    mybyte = (Byte[])(dataSet.Tables["BLOBTEST"].Rows[c - 1]["img"]);
                    MemoryStream ms = new MemoryStream(mybyte);//此处没有问题。可以读到mybyte数组
                    pictureBox1.Image = Image.FromStream(ms);
                }
                con.Close();
            }

好无奈,好多地方看到都是这样写的,不清楚为什么会出错。

[ 本帖最后由 jack_xu2046 于 2010-10-1 22:51 编辑 ]
搜索更多相关主题的帖子: FromStream Image 参数 
2010-10-01 22:44
gameohyes
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:湖南
等 级:版主
威 望:53
帖 子:1275
专家分:3629
注 册:2009-3-5
收藏
得分:18 
可能是保存的时候,没有保存好.或者保存方式错误
详情请参见:
https://down.bccn.net/404.html

C#超级群 74862681,欢迎大家的到来!
2010-10-01 23:48
jack_xu2046
Rank: 2
等 级:论坛游民
帖 子:72
专家分:11
注 册:2008-10-1
收藏
得分:0 
            string filePath = @"C:\Documents and Settings\xuyadong\桌面\Esic\Esic\Shining.jpg";

            FileStream fileByte = File.Open(filePath, FileMode.Open, FileAccess.Read);
            BinaryReader bytes = new BinaryReader(fileByte);
            
            byte[] photo = bytes.ReadBytes((int) fileByte .Length);
丢死人了。
fileByte竟然写成filepath了。怪不得!

[ 本帖最后由 jack_xu2046 于 2010-10-2 00:49 编辑 ]

菜鸟中的菜鸟
2010-10-02 00:09
Askla
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2014-8-2
收藏
得分:0 
。。。
2014-08-02 20:20
快速回复:pictureBox1.Image = Image.FromStream(ms)出错(参数无效)
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.020424 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved