I'm using a view on a binary table to stream out a binary entry to a byte
array.  After the stream is retrieved the database handle is then invalid.
I can check this by adding a watch for session.Database.Tables.Count.  Below
is the piece of code that causes the behavior.  Is this a bug for am I just
performing this operation incorrectly?

Thanks

Matt

using (View binaryView = session.Database.OpenView("SELECT `Data` FROM
`Binary` WHERE `Name` = '{0}'", binaryKeyName))
                {
                    binaryView.Execute();
                    using (Record r = binaryView.Fetch())
                    {
                        if (r != null)
                        {
                            using (MemoryStream ms = new MemoryStream())
                            {
                                using (Stream s = r.GetStream("Data"))
                                {
                                    int bufLength = 32768; //32K
                                    byte[] buffer = new byte[bufLength];
                                    int chunk;
                                    int read = 0;
                                    while ((chunk = s.Read(buffer, 0,
bufLength)) > 0)
                                    {
                                        ms.Write(buffer, 0, chunk);
                                        read += chunk;
                                    }
                                }
                            }
                        }
                        else
                            throw new Exception(string.Format("There must be
a binary entry '{0}'", binaryKeyName));
                    }
------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables 
unlimited royalty-free distribution of the report engine 
for externally facing server and web deployment. 
http://p.sf.net/sfu/businessobjects
_______________________________________________
WiX-devs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wix-devs

Reply via email to