0
我想檢索保存爲數據庫中的斑點數據的圖像。我怎樣才能得到它並將其保存到圖像/位圖對象中?圖像類型的斑點存儲
我想檢索保存爲數據庫中的斑點數據的圖像。我怎樣才能得到它並將其保存到圖像/位圖對象中?圖像類型的斑點存儲
using (SqlConnection conn = new SqlConnection(...))
{
conn.Open();
using (SqlCommand cmd = new SqlCommand("SELECT BlobFieldName FROM Table ...", conn);
using (SqlDataReader reader = cmd.ExecuteReader())
{
if (reader.Read())
{
byte[] bytes = reader["BlobFieldName"] as byte[];
using (FileStream stream = new FileStream(...))
{
stream.Write(bytes, 0, bytes.Length);
stream.Flush();
}
}
}
}
這就是我要開始的。當然,錯誤檢查在這裏是不存在的,我不保證能立即編譯:-)
檢查這個問題 http://stackoverflow.com/questions/9652634/c-sharp-reading-blob-from -sql-server-and-display-to-picture-box – Habib 2012-03-27 12:55:53
什麼數據庫? SQL Server,Oracle,MySQL? – CAbbott 2012-03-27 12:56:52