读取图片到picturebox
private void ShowImage(string sql)
{
SqlConnection conn = new SqlConnection( "Data Source=10.118.15.249;Asynchronous Processing=true;Initial Catalog=test_att;User ID=kqgluser;Password=tlgdh");
//调用方法如:
ShowImage("select Photo from UserPhoto where UserNo='" + userno +"'");
SqlCommand cmd = new SqlCommand(sql, conn);
conn.Open();
byte[] b = (byte [])cmd.ExecuteScalar();
if (b.Length > 0)
{
MemoryStream stream = new MemoryStream(b, true);
stream.Write(b, 0, b.Length);
pbPhoto11.Image = new Bitmap (stream);
stream.Close();
}
conn.Close();
}