; Include ;========= #include #include #include #include #include ;Variables ;========== global $hGui, $hRichEdit1 global $iMsg $screenv=@DesktopHeight *70/100 $screenh=@DesktopWidth *80/100 global $debug = False $hGui = GUICreate("TEST", $screenh, $screenv) $Find = GUICtrlCreateButton("Find",$screenh-75,10,60,25) $label1 = GUICtrlCreateLabel("Use CTRL-V to paste...",(($screenh+23)/2),35,150,20) GUICtrlSetFont( $label1,Default,700 ) $hRichEdit1 = _GUICtrlRichEdit_Create($hGui, "", 10, 75, $screenh-40,$screenv - 150, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL,$WS_HSCROLL )) $save = GUICtrlCreateButton("save",$screenh-140,$screenv-60,60,25) $close = GUICtrlCreateButton("close",$screenh-70,$screenv-60, 60,25) Const $dbuser=InputBox("Database:","Enter DB user id") Const $dbpsw=InputBox("Database:","Enter DB user password") Const $host=InputBox("Database:","Enter Database name (as in tnsnames)") Global $oMyRet[2] Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") main() Func main() GUISetState(@SW_SHOW) While True $iMsg = GUIGetMsg() Switch $iMsg Case $find find_data() Case $save save_data() Case $close _GUICtrlRichEdit_Destroy($hRichEdit1) ; needed unless script crashes Exit Case $GUI_EVENT_CLOSE _GUICtrlRichEdit_Destroy($hRichEdit1) ; needed unless script crashes Exit EndSwitch WEnd EndFunc ;################################## ; Save Data ; ; ;################################## func save_data() connect_to_db() local $myblob = binary(_GUICtrlRichEdit_StreamTovar($hRichEdit1)) $rs=Objcreate("adodb.recordset") $rs.open("select * from test_blob",$OraOBJConn,1,3) with $rs .AddNew .Fields("DOC").Value = $myblob .Update EndWith $rs.close EndFunc ;################################## ; Find Data ; ; ;################################## Func find_data() If $debug then msgbox(0,"debug","Entering Find_data") connect_to_db() $OraobjRecSet = ObjCreate("adodb.recordset") $OraobjRecSet.open("select doc from test_blob where rownum < 2 and length(doc) > 100 ",$OraOBJConn,1,3) MsgBox(0,"debug","count="&$OraobjRecSet.recordcount) local $myblob= binarytostring($OraobjRecSet.fields("DOC").value) _GUICtrlRichEdit_StreamFromVar($hRichedit1,$myblob) $OraobjRecSet.close EndFunc ################################## ; DB connection ; ; ;################################## func connect_to_db() global $connection_SQL = "Provider=OraOLEDB.Oracle;Data Source="&$host&";User Id="&$dbuser&";Password="&$dbpsw ;global $connection_SQL = "Provider='OraOLEDB.Oracle';Data Source='"&$host&"';User Id="&$dbuser&";Password="&$dbpsw global $OraOBJConn = ObjCreate( "ADODB.Connection" ) ; Create a COM ADODB Object with the Beta version $OraOBJConn.ConnectionString =($connection_SQL) $OraOBJConn.Open if @error Then MyErrFunc() EndFunc ;################################## ; ; Com Error Handler ;################################## Func MyErrFunc() $HexNumber = Hex($oMyError.number, 8) $oMyRet[0] = $HexNumber $oMyRet[1] = StringStripWS($oMyError.description, 3) ConsoleWrite("### COM Error ! Number: " & $HexNumber & " ScriptLine: " & $oMyError.scriptline & " Description:" & $oMyRet[1] & @LF) SetError(1); something to check for when this function returns Return EndFunc ;==>MyErrFunc#Include