Jump to content
Sign in to follow this  
Saint

ADODB AppenChunk

Recommended Posts

Saint

Hi,

I want to store a picture (binary data) in an oracle db.

I found some examples with the method 'AppendChunk', but it doesn't want to work.

$connect = "localhost;kopfrechner;kopfrechner"
    $connect = StringSplit($connect,';')
    $ORA_dbc = ObjCreate( "ADODB.Connection")
    ;$ORA_dbc.Open("Driver={Microsoft ODBC for Oracle};Server=" & $connect[1] & ";Uid="&$connect[2]&";Pwd="&$connect[3]&";")
    $ORA_dbc.Open("Driver={Oracle in XE};Server=" & $connect[1] & ";Uid="&$connect[2]&";Pwd="&$connect[3]&";")
    $adores = ObjCreate( "ADODB.RecordSet" )
    $adostream = ObjCreate( "ADODB.Stream" )
    ConsoleWrite("DB Connection Status = " & $adores.State & @CR)
    $adostream.Type = 1
    $adostream.Open
    $adostream.loadFromFile("C:\temp\leo.jpg")
    $ORA_dbc.beginTrans
    $ORA_dbc.execute("UPDATE KR_TBL_TEST SET bild = empty_blob() WHERE id_test = 2")
    With $adores
    ;$SQLstatement="select bild from KR_TBL_TEST where id_test=1;"
        .ActiveConnection=$ORA_dbc
        .Source = "select bild from KR_TBL_TEST where id_test=2"
        .Open
        ;$adofield=ObjCreate("ADODB.Field")
        ;$streamread = $adostream.read
        ;For $adofield in $adores.Fields
        ;   MsgBox(0, "Title", $adofield.Name)
            ;$adofield.AppendChunk ($adostream.read)
        ;Next
        $adores.Fields("bild").AppendChunk($adostream.read)
        ;$adores.AppendChunk($adostream.read)
        .update
        .close
    EndWith
    ;$adostream.read

    $ORA_dbc.commitTrans

    $adostream.Close

All works fine but the AppendChunk doesn't.

Here ist the Error:

D:\AutoIT\test2.au3 (25) : ==> The requested action with this object has failed.:
$adores.Fields("bild").AppendChunk($adostream.read)
$adores.Fields("bild").AppendChunk($adostream.read)^ ERROR

Does anyone of you see the failure or have an idea for a workaround ?

Greets

Saint

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.