乐逍遥

博客园 首页 新随笔 联系 订阅 管理

byte[] aaa= null;

   SqlConnection conn= new SqlConnection();
   conn.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings[0];

   string queryStr = "select top 1 photo from table2(nolock)";
   SqlCommand commd = new SqlCommand(queryStr,conn);

   try
   {
    conn.Open();
    object bbb = commd.ExecuteScalar();
    aaa = bbb as byte[];
    MemoryStream ms = new MemoryStream(aaa);
    Image image=Image.FromStream(ms,true);
    pictureBox1.Image=image;
    ms.Flush();
    ms.Close();
   }
   catch(Exception ex)
   {
    throw ex;
   }
   finally
   {
    conn.Close();
   }

posted on 2007-07-10 10:32  乐逍遥  阅读(262)  评论(0编辑  收藏  举报