您的位置:程序门 -> .net技术 -> c#



vc#数据库(access)编程问题


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


vc#数据库(access)编程问题[已结贴,结贴人:sys0i]
发表于:2007-02-09 10:29:39 楼主
如何实现把picturebox中的图片保存到access数据库中呢,同样,怎么从access库中读取出来,显示到picturebox

谢谢
发表于:2007-02-09 10:40:051楼 得分:20
参考:  

//将图象存到数据库
                void   addimagerow(datatable   tbl,   string   name,   string   filename)
                {
                        filestream   fs   =   new   filestream(filename,   filemode.open);
                        binaryreader   br   =   new   binaryreader(fs);
                        datarow   row   =   tbl.newrow();
                        row[0]   =   name;
                        row[1]   =   br.readbytes((int)br.basestream.length);
                        tbl.rows.add(row);
                        br   =   null;
                        fs   =   null;

                }
                //从数据库中得到图象
                public   image   imagefrombytes(datatable   tbl,int   row)
                {
                        byte[]   b   =(byte[]   )(   tbl.rows[row][ "img "]);
                        memorystream   ms   =   new   memorystream(b);
                        image     img   =   image.fromstream(ms);
                        return   img;
               
                }


快速检索

最新资讯
热门点击