本文介绍了从数据库返回和图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这是一个老问题,我看了很多与我一样的解决方案,但从未和我合作过

系统超出范围!即使我试着用索引来打电话



我尝试过:



if(dReader.HasRows)

{



byte [] previewBytes =(byte [])dReader [Img];

if(previewBytes!= null)

{

context.Response.BinaryWrite(previewBytes);

}

}

i know its an old question and i looked around many solution same as mine but never worked with me
system out of range ! even i try to call it by index

What I have tried:

if (dReader.HasRows)
{

byte[] previewBytes = (byte[])dReader["Img"];
if (previewBytes != null)
{
context.Response.BinaryWrite(previewBytes);
}
}

推荐答案


using (SqlDataAdapter sda = new SqlDataAdapter(strGet, _con))
         {
             DataTable dt = new DataTable();
             sda.Fill(dt);
             byte[] bytes = (byte[])dt.Rows[0]["Img"];
             context.Response.BinaryWrite(bytes);
             context.Response.End();
         }


这篇关于从数据库返回和图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-11 08:57