![](/img/trans.png)
[英]How do I convert an image back from its binary data stored in a database?
[英]How can i retrieve the image stored in binary format from database
我將圖像存儲在數據庫中,並使用c#
作為前端。
我通過將圖像轉換為二進制格式來存儲圖像。
如何從數據庫檢索以二進制格式存儲的圖像?
也許這會有所幫助:
OdbcConnection con = new OdbcConnection(ConnectString);
con.Open();
OdbcCommand checkcommand = new OdbcCommand("SELECT contents FROM MyTable WHERE MyClause", con);
OdbcDataReader checkreader = checkcommand.ExecuteReader();
byte[] array = null;
if (checkreader.Read())
array = (byte[])checkreader.GetValue(0);
else
{
//Error
return false;
}
File.WriteAllBytes("C:\\MyImage.jpeg", array);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.