J
Jeff
When accessing a BLOB from a DB using getbytes, 0 bytes are returned. The
same thing worked with VS2003. The recent environmental change was from
VS2003 to VS2005 and also from .NET 1.1 to .NET 2.0.
/* Here is the function that reads the blob from the db */
private bool GetImageSeq(ref byte[] SeqImage,string PatId,string AdmDate,int
ImgSeq,int SeqSz)
{
long RtnBytes=0,startIndex=0;
string MyStr="",SqlStr="";
SqlStr = "SELECT binimage FROM PUB.Images WHERE patid = '" + PatId +
"' AND admdate = '" + AdmDate + "' AND imgseq = '" + ImgSeq.ToString() +
"'";
OdbcConnection ImgConn = new OdbcConnection(Session["ConnStr"].ToString());
OdbcCommand ImgSel =
new OdbcCommand(SqlStr,ImgConn);
ImgConn.Open();
OdbcDataReader ImgRead;
if (ImgConn.State.ToString() != "Open")
return(false);
else
{
try
{
ImgRead = ImgSel.ExecuteReader(CommandBehavior.SequentialAccess);
MyStr = ImgRead.FieldCount.ToString();
//ImgRead.RecordsAffected.ToString();
ImgRead.Read();
/* with .net 1.1, RtnBytes equaled the blob size.
In .net 2.0, it is zero bytes getting returned. */
RtnBytes = ImgRead.GetBytes(0,startIndex,SeqImage,0,SeqSz);
ImgRead.Close();
}
catch (Exception ex)
{
MyStr = ex.Message;
}
}
ImgConn.Close();
return(true);
}
same thing worked with VS2003. The recent environmental change was from
VS2003 to VS2005 and also from .NET 1.1 to .NET 2.0.
/* Here is the function that reads the blob from the db */
private bool GetImageSeq(ref byte[] SeqImage,string PatId,string AdmDate,int
ImgSeq,int SeqSz)
{
long RtnBytes=0,startIndex=0;
string MyStr="",SqlStr="";
SqlStr = "SELECT binimage FROM PUB.Images WHERE patid = '" + PatId +
"' AND admdate = '" + AdmDate + "' AND imgseq = '" + ImgSeq.ToString() +
"'";
OdbcConnection ImgConn = new OdbcConnection(Session["ConnStr"].ToString());
OdbcCommand ImgSel =
new OdbcCommand(SqlStr,ImgConn);
ImgConn.Open();
OdbcDataReader ImgRead;
if (ImgConn.State.ToString() != "Open")
return(false);
else
{
try
{
ImgRead = ImgSel.ExecuteReader(CommandBehavior.SequentialAccess);
MyStr = ImgRead.FieldCount.ToString();
//ImgRead.RecordsAffected.ToString();
ImgRead.Read();
/* with .net 1.1, RtnBytes equaled the blob size.
In .net 2.0, it is zero bytes getting returned. */
RtnBytes = ImgRead.GetBytes(0,startIndex,SeqImage,0,SeqSz);
ImgRead.Close();
}
catch (Exception ex)
{
MyStr = ex.Message;
}
}
ImgConn.Close();
return(true);
}