Title: ODP.NET and LONG RAW

Help!

I am having trouble loading a JPEG image into Oracle via ODP.NET. I am getting the ORA-00932: Inconsistent datatypes error message when attempting to load the image into a LONG RAW column.

If this wan't an Oracle Apps table, I would use a BLOB column instead of a LONG RAW, but my hands are tied.

I have enclosed the code I am using to attempt to load the image. I know its probably something stupid, but I just can't see it in the pre-long weekend fog.

TIA
Kevin

    Private Sub loadOracle(ByVal intPersonID As Integer, _
                           ByVal img As Image)
        Dim ms As New System.IO.MemoryStream()
        img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg)
        Dim b(ms.Length - 1) As Byte
        ms.Position = 0
        ms.Read(b, 0, ms.Length)

        Dim ob As New OracleBinary(b)

        Dim sp(2) As OracleParameter

        sp(0) = New OracleParameter("i_person_id", OracleDbType.Int64, ParameterDirection.Input)
        sp(0).Value = intPersonID
        sp(1) = New OracleParameter("i_table_name", OracleDbType.Varchar2, ParameterDirection.Input)
        sp(1).Value = "PER_IMAGES"
        sp(2) = New OracleParameter("i_img", ob)
        sp(2).DbType = DbType.Binary
        sp(2).Direction = ParameterDirection.Input
        sp(2).OracleDbType = OracleDbType.LongRaw
        sp(2).Size = ob.Length
        sp(2).Value = ob

        Dim sql As String
        sql = "INSERT INTO hr.per_images (" & _
              "    image_id" & _
              "    ,image" & _
              "    ,parent_id" & _
              "    ,table_name" & _
              ") VALUES (" & _
              "     hr.per_images_s.NEXTVAL" & _
              "    ,:i_img" & _
              "    ,:i_person_id" & _
              "    ,:i_table_name" & _
              ")"
        cOracle.runDML(sql, sp, Me.ToString)
    End Sub

Reply via email to