C# 对SQL Server中Image字段的读写(2)

来源:互联网 发布:仓库淘宝大战在线观看 编辑:程序博客网 时间:2024/05/06 23:25

上篇读取过会,显示时代码如下:

            SqlConnection conn = new SqlConnection("Server=.;DataBase=student;Integrated Security=true;");
            SqlCommand comm = new SqlCommand("select * from [Name]", conn);
            SqlDataAdapter da = new SqlDataAdapter(comm);
            DataSet ds = new DataSet();
            da.Fill(ds, "Name");
            MemoryStream ms = new MemoryStream((byte[])ds.Tables[0].Rows[4][2]);
            pictureBox2.SizeMode = PictureBoxSizeMode.Zoom;
            pictureBox2.Image = Image.FromStream(ms);

原创粉丝点击