Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Access Oracle and Blob files in VB

Posted on 2004-08-31
7
Medium Priority
?
1,713 Views
Last Modified: 2008-01-09

I have an Oracle table:

CREATE TABLE MYOBJECT(
  OBJECTID  NUMBER (9)    NOT NULL,
  OBJECT    BLOB          NOT NULL);


It contains the OBJECTID and an OBJECT.  In my case the OBJECT field is populated by TIFF files (most over 1 megabyte in size).

I wanted a little VB interface to query and display this TIFF.  I did not want to do this via an Oracle Forms.  There are several reasons but I am not going to get into it.

I am able to make an oracle connection:

Public Function connectoracle() As Boolean

Dim logoninfo
Dim SQLStr0
Dim OraDS0
Dim oraval1
Dim oraval2

Dim X

On Error GoTo error5

logoninfo = "scott/tiger"

  'Connect to the Database
  'Create a reference to the OO4O dll
  Set objSession = CreateObject("OracleInProcServer.XOraSession")
  'Create a reference to my database
   
  Set objDataBase = objSession.OpenDatabase("MYDB", logoninfo, 0&)
 
  'The select statement
  SQLStr0 = "SELECT OBJECTID, OBJECT FROM MYOBJECT"
 
  'Run Queries and Create DynaSets
  Set OraDS0 = objDataBase.DbCreateDynaset(SQLStr0, 0&)
 
oraval1 = OraDS0.Fields(0).Value
oraval2 = OraDS0.Fields(1).Value  '<-- This would hold the Tiff.

Exit Function

error5:
Screen.MousePointer = vbDefault
X = MsgBox("Error logging in to Oracle", vbOKOnly, "Error")
connectoracle= False
 
End Function



The issue is that I can not seem to return the BLOB field.  I wanted to get the OBJECT in and then display it into image box or picture box (not sure which works yet).

My first goal is to be able to fetch the BLOB and then display it on the FORM.

Another goal would be for me to specify a single OBJECTID or range of OBJECTIDs and then have those BLOB object printed out (on the default printer) (scaled to print to the page size only if larger than the page, and print out mulitiple pages if it is a mulitple page TIFF).

Has anyone done this via VB?

Does Anyone know how to fetch an Oracle BLOB field?

Does anyone know how to display an Oracle BLOB field?

Does anyone know how to print out an Oracle BLOB field?










0
Comment
Question by:jim_1234567890
[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
  • 4
  • 2
7 Comments
 
LVL 18

Expert Comment

by:JR2003
ID: 11947018
You need a reference in your vb project to "FileMgr 1.1":

FILEMGRLib.FileManager

Here's a sample:

http://www.freevbcode.com/ShowCode.asp?ID=3948

the ImportFromBlob  is what you need.

JR
0
 
LVL 22

Expert Comment

by:DarkoLord
ID: 11947061
If you use ADO to connect to your Oracl database, you can use .GetChunk method and fill byte array with raw image data... then you can save it to temporary file and load it using LoadPicture() function or you can directly convert it to IPicture: http://www.visualbasicforum.com/showthread.php?t=140359&highlight=blob

Also, try to go through this link to see if it helps:
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/VB_Databases/Q_20809962.html

Good luck!
Darko
0
 

Author Comment

by:jim_1234567890
ID: 11947249

That FILEMGFlib.FileManger.

It does dump out to Disk OK.
Via
FileMgr.ImportFromBlob Rs("OBJECT"), "c:\" & GetTimeStamp & "_myobject.tiff"

I did not really want to dump the OBJECTs to disk.  I want to display them in the from, or dump iit directly to a printer.  


0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 18

Expert Comment

by:JR2003
ID: 11947309
Once it's on the disk, say in the temp directory you can display it using the "LoadPicture" function.
I think that even programs like Internet Explorer save the files to temporary storage area first.
0
 

Author Comment

by:jim_1234567890
ID: 11947546

Ok I understand dumping it disk and then reading in via:
Picture1.Picture = LoadPicture("c:\temp.gif")

The ones I am interested in dumping to the screen/printer are the TIFFs.

When I try to issue:
Picture1.Picture = LoadPicture("c:\temp.TIF")
I get an error: "Run-Time error '481':  Invalid picture"


(also How can dump the file directly to the printer (no preview required)?)





0
 
LVL 18

Expert Comment

by:JR2003
ID: 11947754
I don't think you can display a tif file in a picture box or an image control.
Which type control were you going to display the picture on?
0
 
LVL 18

Accepted Solution

by:
JR2003 earned 750 total points
ID: 11947807
You can load it into a WebBrowser control:

    WebBrowser1.Navigate "c:\temp.tif"

You can print from a WebBrowser control, see:

http://support.microsoft.com/default.aspx?scid=kb;EN-US;188271
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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

636 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