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