Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 6 of 6 total
Thread Reading Blob files into Byte Array
Fri, Jun 26 2009 9:21 PMPermanent Link

Pete Hollyer
Tim

My ODBC code works perfectly:
OdbcConnection dbConn = getOdbcConnection();
           OdbcDataReader DataReader;
           OdbcCommand dbCommand = new OdbcCommand();

           SQL = " Select * ";
           SQL += " FROM Task";
           SQL += " WHERE TaskKey = ? ";

           System.Windows.Forms.Application.DoEvents();

           try
           {
               dbConn.Open();
               dbCommand = new OdbcCommand(SQL, dbConn);
               dbCommand.Parameters.Add("@DBTaskKey", OdbcType.Int).Value = lngTaskKey;
               DataReader = dbCommand.ExecuteReader();
               while (DataReader.Read())
               {

                   System.Windows.Forms.Application.DoEvents();

                   this.TaskKey = DataReader.GetInt64(DataReader.GetOrdinal("TaskKey"));
                   this.ListKey = DataReader.GetInt64(DataReader.GetOrdinal("ListKey"));
                   if (DataReader.IsDBNull(DataReader.GetOrdinal("IMAGE_01")))
                       this.IMAGE_01 = null;
                   else
                   {
                       Byte[] FileData = new byte[DataReader.GetBytes(DataReader.GetOrdinal("IMAGE_01"), 0, null, 0, int.MaxValue)];
                       DataReader.GetBytes(DataReader.GetOrdinal("IMAGE_01"), 0, FileData, 0, FileData.Length);
                       m_IMAGE_01 = FileData;
                   }



I'm trying to conver this to ElevateDB 1.09B4


               dbConn.Open();
               dbCommand = new EDBCommand(SQL, dbConn);
               DataReader = (EDBDataReader)dbCommand.ExecuteReader();
               while (DataReader.Read())
               {
                   TreeNode CategoryNode = new TreeNode();
                   CategoryNode.Tag = "LIST-" + DataReader.GetInt64(DataReader.GetOrdinal("ListKey"));
                   CategoryNode.Text = DataReader.GetString(DataReader.GetOrdinal("ListName"));

                   //Load List Image
                   Byte[] FileData = new byte[DataReader.GetBytes(DataReader.GetOrdinal("ListImage"), 0, null, 0, int.MaxValue)];
                   m_ListImage = FileData;
               }


and the Byte Array is correct length but is all "0" thus an invalid Image when I convert the byte array to an image!
Fri, Jun 26 2009 9:58 PMPermanent Link

Pete Hollyer
Sorry I skipped a line in the second c# block it should be:

               dbConn.Open();
               dbCommand = new EDBCommand(SQL, dbConn);
               DataReader = (EDBDataReader)dbCommand.ExecuteReader();
               while (DataReader.Read())
               {
                   TreeNode CategoryNode = new TreeNode();
                   CategoryNode.Tag = "LIST-" + DataReader.GetInt64(DataReader.GetOrdinal("ListKey"));
                   CategoryNode.Text = DataReader.GetString(DataReader.GetOrdinal("ListName"));

                   //Load List Image
                   Byte[] FileData = new byte[DataReader.GetBytes(DataReader.GetOrdinal("ListImage"), 0, null, 0, int.MaxValue)];
                   DataReader.GetBytes(DataReader.GetOrdinal("ListImage"), 0, FileData, 0, FileData.Length);
                   m_ListImage = FileData;
                   }

FileData is the correct length...but all "0"s

Pete
Fri, Jun 26 2009 10:24 PMPermanent Link

Pete Hollyer
I downloaded 2.2B14 and it has the same issue....
Mon, Jun 29 2009 11:58 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Pete,

<< I downloaded 2.2B14 and it has the same issue.... >>

I'll check it out and let you know what I find out.

--
Tim Young
Elevate Software
www.elevatesoft.com

Mon, Jun 29 2009 2:47 PMPermanent Link

Pete Hollyer
Thanks!

I believe its still a problem...but I have discovered a work around.

Somewhere on here I came across you telling someone about a GetValue method that returns an Object or Object[] for blob files....I've managed
to get that one working...

if (DataReader.IsDBNull(DataReader.GetOrdinal("IMAGE_01")))
   this.IMAGE_01 = null;
else
   {
       object ObjectData = DataReader.GetValue(DataReader.GetOrdinal("IMAGE_01"));
       byte[] FileData = (byte[])ObjectData;
       m_IMAGE_01 = FileData;
    }
Tue, Jun 30 2009 2:15 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Pete,

<< I believe its still a problem...but I have discovered a work around.

Somewhere on here I came across you telling someone about a GetValue method
that returns an Object or Object[] for blob files....I've managed to get
that one working... >>

Nice job - that was going to be my suggestion because it is indeed an issue
with the other method.

--
Tim Young
Elevate Software
www.elevatesoft.com

Image