Modify

Opened 13 years ago

Closed 12 years ago

Last modified 12 years ago

#2309 closed Bug (Fixed)

ObjEvent on ADO.Connection not returning strings

Reported by: danielcovington Owned by: Jon
Milestone: 3.3.11.3 Component: AutoIt
Version: 3.3.8.1 Severity: None
Keywords: Cc:

Description

I have Created an Event Handler for ADO.CONNECTION the functions do fire but the strings contain gibberish. The Long and Int return okay. I have looked up the interface and they should be returning Wstrings. I was told to submit this as a bug by trancexx .

Below is the Function prototype givin by PowerBasic COM browser.

WillConnect <6> (ByRef InOut ConnectionString As WString, ByRef InOut UserID As WString, ByRef InOut Password As _
WString, ByRef InOut Options As Long, ByRef InOut adStatus As Long, Byval pConnection As IntConnection)

#AutoIt3Wrapper_UseX64=n
#include

const $ConnInterface = "ConnectionEvents"

$conn = ObjCreate("ADODB.Connection")
$connEvent = ObjEvent($conn,"EVENTS_",$ConnInterface)

if @error then
Msgbox(0,"AutoIt COM Test", _
"ObjEvent: Can't use event interface '"& $ConnInterface &"'. Error code: " & hex(@error,8))
exit

endif


$conn.open ("Provider=SQLNCLI10;Server=ServerName;Database=Database;Uid=UID;pwd=pwd")

$conn.close()


Func EVENTS_ConnectComplete($ugh3,$ugh,$ugh1)

MsgBox(0,"ADO EVENT","Connected to DataBase")

EndFunc
Func EVENTS_Disconnect($ugh4,$ugh5)

MsgBox(0,"ADO EVENT","Disconnected from DataBase")

endFunc
Func EVENTS_WillConnect($ConnectionString,$val2,$val3,$val4,$val5,$val6)
ConsoleWrite($ConnectionString&@CRLF&$val2&@CRLF&$val3&@CRLF&$val4&@CRLF&$val5&@CRLF&$val6&@CRLF)
Msgbox(0,"Connection String",string($ConnectionString))
endFunc

Attachments (0)

Change History (5)

comment:1 by trancexx, 13 years ago

The issue was referenced by rev [7178]. That means the bug no longer exists. Unfortunatly this particular code example shows another issue with inability of internal string class to accept NULL pointers. That's why VARIANT to Variant function for VT_BSTR|VT_BYREF type must also check for possibly referenced NULL BSTR.
The other option is to finally allow NULL pointers for string class.

comment:2 by Jon, 13 years ago

Resolution: Rejected
Status: newclosed

comment:3 by J-Paul Mesnage, 13 years ago

Resolution: Rejected
Status: closedreopened

No sure what has really be fixed but now the script does not execute the line following $conn.open()
so I reopen it for diagnostic. I hope trancexx can do it. Many thanks for her.

Local $oMyError = ObjEvent("AutoIt.Error", "_ErrFunc") ; Initialize a COM error handler

Const $ConnInterface = "ConnectionEvents"

Local $conn = ObjCreate("ADODB.Connection")
Local $connEvent = ObjEvent($conn, "EVENTS_", $ConnInterface)

If @error Then
	MsgBox(0, "AutoIt COM Test", _
			"ObjEvent: Can't use event interface '" & $ConnInterface & "'. Error code: " & Hex(@error, 8))
	Exit

EndIf

Local $ret = $conn.open("Provider=SQLNCLI10;Server=ServerName;Database=Database;Uid=UID;pwd=pwd")
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $ret = ' & $ret & @CRLF & '>Error code: ' & @error & '    Extended code: 0x' & Hex(@extended) & @CRLF) ;### Debug Console

$conn.close()

Func EVENTS_ConnectComplete($ugh3, $ugh, $ugh1)
	#forceref $ugh3, $ugh, $ugh1

	MsgBox(0, "ADO EVENT", "Connected to DataBase")

EndFunc   ;==>EVENTS_ConnectComplete

Func EVENTS_Disconnect($ugh4, $ugh5)
	#forceref $ugh4, $ugh5

	MsgBox(0, "ADO EVENT", "Disconnected from DataBase")

EndFunc   ;==>EVENTS_Disconnect

Func EVENTS_WillConnect($ConnectionString, $val2, $val3, $val4, $val5, $val6)
	ConsoleWrite("connectionstring="&$ConnectionString & @CRLF &"val2="& $val2 & @CRLF &"val3="& $val3 & @CRLF &"val4="& $val4 & @CRLF &"val5="& $val5 & @CRLF &"val6="& $val6 & @CRLF)
	MsgBox(0, "Connection String", String($ConnectionString))
EndFunc   ;==>EVENTS_WillConnect

Func _ErrFunc($oError)
    ; Do anything here.
    MsgBox(0, "AutoIt.Error", "err.number is: " & @TAB & $oError.number & @CRLF & _
            "err.windescription:" & @TAB & $oError.windescription & @CRLF & _
            "err.description is: " & @TAB & $oError.description & @CRLF & _
            "err.source is: " & @TAB & $oError.source & @CRLF & _
            "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
            "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
            "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
            "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
            "err.retcode is: " & @TAB & $oError.retcode & @CRLF & @CRLF)
EndFunc   ;==>_ErrFunc

comment:4 by Jon, 12 years ago

Milestone: 3.3.11.3
Owner: set to Jon
Resolution: Fixed
Status: reopenedclosed

Fixed by revision [9680] in version: 3.3.11.3

comment:5 by Jon, 12 years ago

Fixed by revision [9696] in version: 3.3.11.3

Modify Ticket

Action
as closed The owner will remain Jon.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.