?
Solved

How to show BLOB data in webBrowser control directly from memory stream

Posted on 2008-06-10
3
Medium Priority
?
2,351 Views
Last Modified: 2008-08-16
Hi, I have a question about C#, Oracle and WebBrowser control.
I have Oracle database, table with BLOB field and I want to show its value
in webBrowser control in Windows Forms Application.
My task is to show data in webBrowser directly from memory stream.
Now I am using ShowBLOBs but is it posible to change ShowBLOBs
not to use temporary file and FileStream to show Blob field value
from database in webBrowser?


public override void ShowBLOBs()
{
  base.ShowBLOBs();
                  
  int Key = myBusinessObject.KeyValue;
  if (Key <= 0)
    return;

  object blob = myBusinessObject.readBlobFieldValue(BlobColumn);
  string tmpFile = @"c:\temp\doc_" + Key.ToString() + "." + BlobType;

  if (blob != null)
  {
    Byte[] byteBLOBData = blob as Byte[];

    if (byteBLOBData != null)
    try
    {
      MemoryStream ms = new MemoryStream(byteBLOBData);
      if (File.Exists(tmpFile))
        File.Delete(tmpFile);
      FileStream fs = new FileStream(tmpFile, FileMode.CreateNew);
                                    
      ms.WriteTo(fs);
      fs.Close();
      fs.Dispose();
      Application.DoEvents();

      ms.Close();
      ms.Dispose();

                  
      Application.DoEvents();
                                    
      //
     if (BlobType == "mht")
       webBrowser1.Url = new Uri(tmpFile); //for MHT
     else
       Process.Start(tmpFile);

    }
    catch (Exception ex)
    {
       MessageBox.Show("Error - showing file:" + Environment.NewLine + ex.Message);
    }
  }
}
            
0
Comment
Question by:ela1109
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 1500 total points
ID: 21758507
The WebBrowser control exposes the DocumentStream, so you might be able to use that.
0
 

Author Comment

by:ela1109
ID: 21829522
I changed my code to

public override void ShowBLOBs()
{
  base.ShowBLOBs();
  int Key = myBusinessObject.KeyValue;
  if (Key <= 0)
      return;

  object blob = myBusinessObject.readBlobFieldValue(BlobColumn);
  string tmpFile = @"c:\temp\doc_" + Key.ToString() + "." + BlobType;

  if (blob != null)
  {
      Byte[] byteBLOBData = blob as Byte[];

      if (byteBLOBData != null)
      try
      {
        MemoryStream ms = new MemoryStream(byteBLOBData);
                                                                        
        //
        if (BlobType == "mht")
          webBrowser1.DocumentStream = ms; //for MHT
        else
          Process.Start(tmpFile);
                           }
        catch (Exception ex)
      {
        MessageBox.Show("Error - showing file:" + Environment.NewLine + ex.Message);
      }
  }
}
            
and it works BUT
because my Blob field content is Word document I see something like


MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_NextPart_01C80FF5.6C1133D0"
This document is a Single File Web Page, also known as a Web Archive file.
If you are seeing this message, your browser or editor doesn't support Web Archive files.
Please download a browser that supports Web Archive, such as Microsoft Internet Explorer.
------=_NextPart_01C80FF5.6C1133D0
Content-Location: file:///C:/2518D811/DOC_1003_1.htm
Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset="us-ascii"
<!--[if supportFields= ]> = FORMTEXT <![e= ndif]-->725000
 
 
<!--[if supportFi= elds]> FORMTEXT <![endif]-->2356<![endif]-->
 
How to show real document made in Microsoft Word 2003?
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 21830045
And, that I wouldn't know.  :(
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question