从sql server 中读取二进制图片

/**//// <summary>
        
/// 显示示带图片的记录
        
/// </summary>
        
/// <param name="sender"></param>
        
/// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            string sql = "";
            sql = "SELECT OrName,OrTel, Orimage FROM Organize  WHERE OrID = 1"//
            SqlConnection conn = new SqlConnection(DBConnectioin.conStr);          
            SqlCommand cmd = new SqlCommand(sql, conn);
            conn.Open();
            SqlDataReader reader = cmd.ExecuteReader();
            reader.Read();
            this.textBox1.Text =(string) reader["OrName"];
            textBox2.Text = (string)reader["OrTel"];
            MemoryStream ms = new MemoryStream((byte[])reader["Orimage"]);
            Image image = Image.FromStream(ms, true);

            reader.Close();
            conn.Close();
            pictureBox1.Image = image;
        }
posted @ 2012-06-04 09:14  跟着阿笨一起玩.NET  阅读(2225)  评论(0编辑  收藏  举报