Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: store bitmap into oracle7 database

Re: store bitmap into oracle7 database

From: Bob Weber <bweber_at_onramp.net>
Date: 1997/07/04
Message-ID: <01bc88ac$bf886230$0b8e60cc@weberhq>#1/1

Here's a quick little snippet! I just happen to be putting together a skeleton that I'll be using for moving images from a digital camera to an ORACLE Db.

    If SQLAllocStmt(hdbc, hStmt) <> SQL_SUCCESS Then MsgBox "start: AllocStmt Failed"

    SQLFetchStr = "SELECT max(id) FROM DC50IMAGES"     If SQLExecDirect(hStmt, SQLFetchStr, Len(SQLFetchStr)) <> SQL_SUCCESS Then

        MsgBox "ExecDirect Failed"
        X = SQLError(henv, hdbc, hStmt, SQLState, NativeErr, ErrMsg, 255,
ErrMsgLen)
        MsgBox ErrMsg

    End If
    If SQLFetch(hStmt) <> SQL_SUCCESS Then
        MsgBox "SQLFetch failed"
        X = SQLError(henv, hdbc, hStmt, SQLState, NativeErr, ErrMsg, 255,
ErrMsgLen)
        MsgBox ErrMsg

    End If
    If SQLGetData(hStmt, 1, SQL_C_CHAR, strBuffer, Len(strBuffer), Len(strBuffer)) <> SQL_SUCCESS Then
        MsgBox "GetData failed"
        X = SQLError(henv, hdbc, hStmt, SQLState, NativeErr, ErrMsg, 255,
ErrMsgLen)
        MsgBox ErrMsg

    End If
    If SQLFreeStmt(hStmt, SQL_DROP) <> SQL_SUCCESS Then MsgBox "FreeAlloc Failed"     

    If SQLAllocStmt(hdbc, hStmt) <> SQL_SUCCESS Then MsgBox "AllocStmt Failed"

    SQLInsert = "INSERT INTO DC50IMAGES (id) VALUES ("     SQLInsert = SQLInsert + Str(1) + ")"     If SQLExecDirect(hStmt, SQLInsert, Len(SQLInsert)) <> SQL_SUCCESS Then

        MsgBox "ExecDirect Failed"
        X = SQLError(henv, hdbc, hStmt, SQLState, NativeErr, ErrMsg, 255,
ErrMsgLen)
        MsgBox ErrMsg

    End If
    If SQLFreeStmt(hStmt, SQL_CLOSE) <> SQL_SUCCESS Then MsgBox "FreeAlloc Failed"

    If SQLAllocStmt(hdbc, hStmt) <> SQL_SUCCESS Then MsgBox "start: AllocStmt Failed"

    SQLUpdate = "UPDATE DC50IMAGES SET IMAGEDATA=? WHERE id=" + Str(1)     lngBufferLength = FileLen("Tester.JPG")     ReDim bytBuffer(lngBufferLength)
    Open "Tester.JPG" For Binary As #1
    Do While Not EOF(1)

        Get #1, , bytBuffer
    Loop
    Close #1
    If SQLBindParameter(hStmt, 1, SQL_PARAM_INPUT, SQL_C_BINARY, SQL_LONGVARBINARY, lngBufferLength, 0, bytBuffer(0), lngBufferLength, lngBufferLength) <> SQL_SUCCESS Then

        MsgBox "BindParameter Failed"
        X = SQLError(henv, hdbc, hStmt, SQLState, NativeErr, ErrMsg, 255,
ErrMsgLen)
        MsgBox ErrMsg

    End If
    If SQLExecDirect(hStmt, SQLUpdate, Len(SQLUpdate)) <> SQL_SUCCESS Then
        MsgBox "ExecDirect failed"
        X = SQLError(henv, hdbc, hStmt, SQLState, NativeErr, ErrMsg, 255,
ErrMsgLen)
        MsgBox ErrMsg

    End If
    If SQLFreeStmt(hStmt, SQL_DROP) <> SQL_SUCCESS Then MsgBox "FreeAlloc Failed"

Juan Buiza Camacho <jbuiza_at_net.disbumad.es> wrote in article <33BAC2FF.37DB_at_net.disbumad.es>...
> I have a bitmap and I need store it into Oracle7 database using API
> ODBC. How I can do it? Any ideas? I've read a little about some classes
> that exchange this information with the database - CLongBinary, I
> think-. Is it right?.
>
> I use Visual C++ 4.0 for Windows 95/NT.
>
> Thanks in advance..
>
> Juan Buiza Camacho
> jbuiza_at_net.disbumad.es
>
Received on Fri Jul 04 1997 - 00:00:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US