| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 5502 人关注过本帖
标题:pictureBox1.Image = Image.FromStream(ms)出错(参数无效)
取消只看楼主 加入收藏
jack_xu2046
Rank: 2
等 级:论坛游民
帖 子:72
专家分:11
注 册:2008-10-1
结帖率:81.82%
收藏
已结贴  问题点数:18 回复次数:1 
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
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
快速回复:pictureBox1.Image = Image.FromStream(ms)出错(参数无效)
数据加载中...
 
   



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

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