No, the bytes field is null. bytes is null after the ExecuteScalar call and
"davebythesea" wrote:
> Does this work for you -
>
> private bool GetImageSeq(ref byte[] SeqImage, string PatId, string AdmDate,
> int ImgSeq, int SeqSz)
> {
> string 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);
>
> try
> {
> ImgConn.Open();
>
> byte[] bytes = (byte[])ImgSel.ExecuteScalar();
>
> if (bytes.Length > 0)
> {
> SeqImage = bytes;
> return true;
> }
> else
> {
> return false;
> }
> }
> catch(Exception ex)
> {
> //
>
> return false;
> }
> finally
> {
> ImgSel.Dispose();
> ImgConn.Close();
> ImgConn.Dispose();
> }
> }
>
> "Jeff" wrote:
>
> > Thanks for your response Wen,
> >
> > The SeqImage.Length for this instance would be 500,000. But that's what it
> > is declared at in the a function called GetImageDb. The byte array itself,
> >
> > is just a bunch of empty bytes.
> >
> > The size of the blob data is stored in the database table in a field called
> > SeqSz. We convert that to an int, and then define a new byte array of that
> > size.
> >
> > SeqSz = Convert.ToInt32(r["seqsz"].ToString());
> >
> > byte[] SeqByte = new Byte[SeqSz];
> >
> > The database we are using is a Progress database version 10.0B.
> >
> > The odbc driver is:
> >
> > DataDirect 4.20 32-BIT OpenEdge SQL v10.0B
> >
> > This function (GetImageDb) calls the GetImageSeq function.
> >
> > private bool GetImageDb(int ImageSize,ref byte[] PatImage,string
> > PatId,string AdmDate)
> >
> > {
> >
> >
> > DataSet dsImage = new DataSet();
> >
> > string ConnStr;
> >
> > int Result = 0;
> >
> > int SeqSz=0,SeqNum,StartByte;
> >
> >
> >
> > if (Session["ConnStr"] == null)
> >
> > return(false);
> >
> > ConnStr = Session["ConnStr"].ToString();
> >
> >
> >
> >
> >
> >
> > string SqlStr="";
> >
> > SqlStr = "SELECT patid,admdate,imagesize,imgseq,seqsz FROM PUB.Images WHERE
> > patid = '" + PatId +
> >
> > "' AND admdate = '" + AdmDate + "'" ;
> >
> > OdbcDataAdapter daApp = new OdbcDataAdapter(SqlStr,ConnStr);
> >
> >
> > daApp.SelectCommand.Parameters.Add("patid",OdbcType.VarChar);
> >
> > daApp.SelectCommand.Parameters.Add("admdate",OdbcType.Date);
> >
> > daApp.SelectCommand.Parameters["patid"].Value = PatId;
> >
> > daApp.SelectCommand.Parameters["admdate"].Value = AdmDate;
> >
> > try
> >
> > {
> >
> > Result = daApp.Fill(dsImage,"images");
> >
> > }
> >
> > catch (Exception ex)
> >
> > {
> >
> > lblError.Text = ex.Message;
> >
> > return(false);
> >
> > }
> >
> > if (Result > 0)
> >
> > {
> >
> > foreach (DataRow r in dsImage.Tables["images"].Rows)
> >
> > {
> >
> > try
> >
> > {
> >
> > SeqSz = Convert.ToInt32(r["seqsz"].ToString());
> >
> > SeqNum = Convert.ToInt16(r["imgseq"].ToString());
> >
> > StartByte = (SeqNum - 1) * 500000;
> >
> > byte[] SeqByte = new Byte[SeqSz];
> >
> > GetImageSeq(ref SeqByte,PatId,AdmDate,SeqNum,SeqSz);
> >
> > SeqByte.CopyTo(PatImage,StartByte);
> >
> > //BuildImage(ref PatImage,SeqByte,StartByte,SeqSz);
> >
> >
> >
> > }
> >
> > catch (Exception ex)
> >
> > {
> >
> > lblError.Text = ex.Message;
> >
> > return(false);
> >
> > }
> >
> >
> >
> > }
> >
> >
> > return(true);
> >
> > }
> >
> > else
> >
> > return(false);
> >
> >
> > }
> >
> >
> >
> >
> > ""Wen Yuan Wang [MSFT]"" wrote:
> >
> > > Hello AIMDeveloper,
> > >
> > > According to your description, you face an issue that
> > > ODBCDataReader.GetBytes(0,startIndex,SeqImage,0,SeqSz) returns Zero after
> > > you changed environment from .net 1.1 to .net 2.0, correct? If I
> > > misunderstood anything here, please don't hesitate to correct me.
> > >
> > > As far as I know, all break-change in system.data in .net 2.0 runtime has
> > > been listed in the following article. But, I cannot getbytes method in it.
> > >
http://msdn2.microsoft.com/en-us/netframework/aa497245.aspx > > > [System.Data Run-Time Breaking Changes]
> > >
> > > In general, OdbcDataReader.GetBytes method returns the actual number of
> > > bytes read. This should be the same value as SeqSz. Have you checked the
> > > SeqImage after GetBytes method? Is there any data in SeqImage?
> > >
> > > RtnBytes = ImgRead.g.GetBytes(0, startIndex, SeqImage, 0, SeqSz);
> > > System.Console.Write(SeqImage.Length);
> > >
> > > At last, could you let me know where your application gets data? Is it
> > > Excel or Access Database? I will try to reproduce the issue on my side.
> > >
> > > Please feel free to let us know if you have any more concern. We are glad
> > > to assist you.
> > > Have a great day,
> > > Best regards,
> > > Wen Yuan
> > >
> > > Microsoft Online Community Support
> > > Delighting our customers is our #1 priority. We welcome your comments and
> > > suggestions about how we can improve the support we provide to you. Please
> > > feel free to let my manager know what you think of the level of service
> > > provided. You can send feedback directly to my manager at:
> > > msdnmg@microsoft.com.
> > > ==================================================
> > > Get notification to my posts through email? Please refer to
> > >
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif > > > ications.
> > > Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
> > > where an initial response from the community or a Microsoft Support
> > > Engineer within 1 business day is acceptable. Please note that each follow
> > > up response may take approximately 2 business days as the support
> > > professional working with you may need further investigation to reach the
> > > most efficient resolution. The offering is not appropriate for situations
> > > that require urgent, real-time or phone-based interactions or complex
> > > project analysis and dump analysis issues. Issues of this nature are best