我原来用过的一段Show Picture的代码,图片是image格式的,可能不怎么好,但能用。其他地方,你还可以在
http://dotnet.aspx.cc/   这个地方讲的很清楚。你试试private void ShowPicture()
{
string strSel="select content from tblitem where itemcode='"+Control1.Text+"' and sequence='"+Control2.Text+"'";
SqlDataAdapter da2 = new SqlDataAdapter(strSel,share.cn);
SqlCommandBuilder MyCB = new SqlCommandBuilder(da2);
DataSet ds2 = new DataSet("MyImages");
byte[] MyData= new byte[0];
da2.Fill(ds2, "MyImages");
if (ds2.Tables["MyImages"].Rows.Count>0)
{
DataRow myRow;
myRow=ds2.Tables["MyImages"].Rows[0];
if(myRow["Content"].ToString()!="")
{
MyData =  (byte[])myRow["Content"];
int ArraySize = new int();
ArraySize = MyData.GetUpperBound(0); 
string address=Server.MapPath("temp");
if(j==1)
{
System.IO.File.Delete(address+@"\"+"5.gif");
}
else
{
System.IO.File.Delete(address+@"\"+(j-1).ToString()+".gif");
}
if (j>5)
{
j=1;
}
try
{
System.IO.File.Delete(address+@"\"+j.ToString()+".gif");
}
catch
{}
FileStream fs = new FileStream(address+@"\"+j.ToString()+".gif",FileMode.OpenOrCreate,FileAccess.Write);
fs.Write(MyData, 0,ArraySize);
Image1.ImageUrl="temp"+"\\"+j.ToString()+".gif";
fs.Close();
j++;
Image1.Visible=true;
}
else
{
Image1.Visible=false;
}
}
}

解决方案 »

  1.   

    假设存图片的表为
    image:
    xh      varchar2(5)
    photo   blobstring sXH = "12345"
    OracleConnection conn = new OracleConnection("Password=test;User ID=test;Data Source=test");
    string sSQL = "select photo from image where xh = '"+sXH+"'";
    OracleDataAdapter adt = new OracleDataAdapter(sSQL,conn);
    DataSet ds = new DataSet();
    adt.Fill(ds);
    //写临时文件
    Byte[] FileByteArray;
    object aaa = ds.Tables[0].Rows[0]["photo"];
    FileByteArray = (Byte[])aaa;
    string sPath = @"C:\result.jpg";
    FileStream fs = new FileStream(sPath,FileMode.OpenOrCreate,FileAccess.Write,FileShare.None);
    fs.Write(FileByteArray,0,FileByteArray.Length);
    fs.Flush();
    fs.Close();
    Image.ImageUrl = sPath;
      

  2.   

    zhouyonghua0520() 按照你的方法解决问题,谢谢,但是需要安装一个OracleClient的Dll!结分!
    skytear(将进酒)你的方法是解决SQLserver的,不管怎样,先谢了!