Results 1 to 7 of 7

Thread: Resolved: Image in Oracle?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2001
    Location
    Florida
    Posts
    213

    Resolved: Image in Oracle?

    Can images be stored in Oracle? I am using ImageLibrary_tutor of Beacon with the database is Oracle. Someone told me that image might be stored in Oracle as bfile (binary file lob) but when I try to add the image into the table I got :

    OIP-04125: Invalid file type. Does anyone know what is it and how to fix? I don't have Oracle Documentation installed to look it up.

    Thanks alot.
    -vb
    Last edited by vbvbvbvb; Mar 26th, 2002 at 01:45 PM.

  2. #2
    Fanatic Member Gaffer's Avatar
    Join Date
    Nov 2000
    Location
    London
    Posts
    828
    If you are using version of Oracel less than 8i, use datatype Long Raw. 8i and above, use BLOB

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 2001
    Location
    Florida
    Posts
    213
    Thanks.

    I'm using O040 to connect to Oracle 8.1.6
    VB Code:
    1. Private Session As Object 'OracleInProcServer.OraSession
    2. Private Database As Object 'OracleInProcServer.OraDatabase
    3. Private rs As Object 'OracleInProcServer.OraDynaset
    4. Private Const ORADB_NOWAIT = &H2&  'same as ORADB_NOWAIT = 2
    5. Private Const ORADYN_DEFAULT = &H0&
    6.  
    7. Private Sub Form_Load()
    8.    Dim strSQL As String
    9.      
    10.    Set Database = Nothing
    11.    Set Session = CreateObject("OracleInProcServer.XOraSession")
    12.    Set Database = Session.OpenDatabase(DatabaseName, "user/pass", ORADB_NOWAIT)
    13.    
    14.    Set rs = Nothing
    15.    
    16.    strSQL = "SELECT * FROM Image"
    17.    Set rs = Database.CreateDynaset(strSQL, ORADYN_DEFAULT)
    18.        
    19.    FillFields .
    20.    
    21. End Sub
    22.  
    23. Everything seems OK until after an image is added:
    24.  
    25. Public Sub FillFields()
    26.  
    27.    If Not (rs.BOF And rs.EOF) Then
    28.       txtDescription.Text = rs.Fields("Description")
    29.       Set Image1.DataSource = rs 'setting image1's datasource->
    30. ->run time error '13' type mismatch
    31. 'I tried both Long Raw & BLOB and got same error
    32.  
    33.       Image1.DataField = "Picture" 'set its datafield.
    34.    End If

    Everything becomes harder to handle when it related to Oracle...
    Last edited by vbvbvbvb; Mar 22nd, 2002 at 03:13 PM.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Sep 2001
    Location
    Florida
    Posts
    213
    Any one ever tried Beacon's tutor using Oracle instead of Access?

  5. #5
    PowerPoster Beacon's Avatar
    Join Date
    Jan 2001
    Location
    Pub Floor
    Posts
    3,188
    Not that i know of!!
    Sorry i dont have oracle but this link may help:

    tektips

    good luck
    b

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Sep 2001
    Location
    Florida
    Posts
    213
    Thanks for your response. I found a couple site talking about image & oracle but they didn't point Image.DataSource to rs. Instead they load the picture
    Image.LoadPicture = Dialog.Filename

    When the form is loaded, image is not displayed until they select a pic from the dialog. That's not what I want. I want to load pic from Oracle database.

    I can add new pic and see that they are in my table but just cannot retrieve them.

    Thanks anyways.

    -vb

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Sep 2001
    Location
    Florida
    Posts
    213
    If you want to use Beacon's code and Oracle database, here it is:

    VB Code:
    1. 'Picture is Long Raw
    2.  
    3. Private cn As ADODB.Connection
    4. Private rs As ADODB.Recordset
    5. Dim strConn As String
    6.  
    7. Private Sub Form_Load()
    8.    Dim strSQL
    9.  
    10.    Set cn = New ADODB.Connection
    11.    strConn = "UID=user;PWD=password;" & _
    12.              "driver={Microsoft ODBC for Oracle};" & _
    13.              "SERVER=server;"
    14.    cn.Open strConn
    15.    
    16.    strSQL = "Select PicId, Description, Picture from Image"
    17.    Set rs = New ADODB.Recordset
    18.    rs.CursorType = adOpenKeyset
    19.    rs.LockType = adLockOptimistic
    20.    rs.Open strSQL, cn
    21.    
    22.    FillFields
    23.    
    24. End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width