Jump to content

Problems with GUI and 3.1.1.++


dwerznec
 Share

Recommended Posts

Hello,

I tried to create a GUI for a MS SQL Server, so I'm able to get, change and add data to the database without using the MS Client tools and having an more comfortable GUI to do so.

The GUI worked fine as long as I used Version 3.1.0++ (last one was 3.1.0.15T), but as soon as I changed files to the new 3.1.1.++ Versions the GUI opens up, the listview is filled with items and and then the GUI just closes.

With the older version it worked fine.

I can post the source code if required, but it's a bit long (about 600 lines).

Any suggestions ?

Link to comment
Share on other sites

  • Developers

I can post the source code if required, but it's a bit long (about 600 lines).

Any suggestions ?

<{POST_SNAPBACK}>

It would help if you post a piece of code (As short as possible) that shows the problem....

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

I try just to post the problematic parts :)

Func GUI()

GUICreate("ICT Services Inventory", 1024, 768, -1, -1, $WS_MAXIMIZEBOX)

GUISetState(@SW_SHOW)

.

.

get_Distinct()

.

.

EndFunc

Func getDistinct()

$adoCon = ObjCreate ("ADODB.Connection")

$adoCon.Open ($DSN_Connect)

$adoRs = ObjCreate ("ADODB.Recordset")

$adoSQL = "SELECT DISTINCT Gerätetyp FROM [HW-Invent]"

$adoRs.CursorType = 2

$adoRs.LockType = 3

$adoRs.Open($adoSql, $adoCon)

With $adoRs

If .RecordCount Then

While Not .EOF

$cmboVal[2] = $cmboVal[2] & .Fields("Gerätetyp").Value & "|"

.MoveNext

WEnd

EndIf

EndWith

$adoCon.Close

.

.

EndFunc

As soon as the getDistinct() Function is called, the GUI dies.

The whole getDistinct() Function is just a collection of SQL statements with its results written to an according Array.

All the variables used are declared as Global.

Link to comment
Share on other sites

  • Developers

I try just to post the problematic parts :)

As soon as the getDistinct() Function is called, the GUI dies.

The whole getDistinct() Function is just a collection of SQL statements with its results written to an according Array.

All the variables used are declared as Global.

<{POST_SNAPBACK}>

So when the getDistinct() is done you go into a While...Wend loop somewhere else in the script waiting for messages from the GUI ? Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

I try just to post the problematic parts ;)

....

Func getDistinct()

..

$adoCon.Close

        .

EndFunc

<{POST_SNAPBACK}>

This could also be a COM related problem.

Have you already checked, without GUI, if the getDistinct() function still operates properly?

Regards,

-Sven

Link to comment
Share on other sites

@jdbe

after getting all the data necessary for the gui, im waiting for gui messages with a while ... wend loop, so this should be ok

@svenp

just tried getDistinct() without GUI and having placed a msgbox after getDistinct(), but the msgbox doesn't show up, tried a msgbox at the beginning of getDistinct, this one shows up, but the one at the end of the function or the one after this function doesn't show up at all.

This is the Exit code SciTe gets, when trying to run the script :

Exit code: -1073741819

Maybe this could help

Link to comment
Share on other sites

  • Developers

@jdbe

after getting all the data necessary for the gui, im waiting for gui messages with a while ... wend loop, so this should be ok

@svenp

just tried getDistinct() without GUI and having placed a msgbox after getDistinct(), but the msgbox doesn't show up, tried a msgbox at the beginning of getDistinct, this one shows up, but the one at the end of the function or the one after this function doesn't show up at all.

This is the Exit code SciTe gets, when trying to run the script :

Exit code: -1073741819

Maybe this could help

<{POST_SNAPBACK}>

you could put the debug:trace console lines in your code so you can see when it stops running to pinpoint the line causing the error.....

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

...

@svenp

....

This is the Exit code SciTe gets, when trying to run the script :

Exit code: -1073741819

Maybe this could help

<{POST_SNAPBACK}>

The exit code is in hex 0xC0000005 and that's an Access Violation Exception error.

It's difficult for me to reproduce the code, but you could debug the COM code also by using the "AutoIt.Error" object.

Insert this line right before you call the function getDistinct():

$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")

Then somewhere else in the code, place this temporary function:

; This is my custom error handler
Func MyErrFunc()

  $HexNumber=hex($oMyError.number,8)

  Msgbox(0,"","We intercepted a COM Error !"  & @CRLF               & @CRLF & _
        "err.description is: "  & @TAB & $oMyError.description  & @CRLF & _
        "err.windescription:"    & @TAB & $oMyError.windescription & @CRLF & _
        "err.number is: "        & @TAB & $HexNumber              & @CRLF & _
        "err.lastdllerror is: "   & @TAB & $oMyError.lastdllerror   & @CRLF & _
        "err.scriptline is: "    & @TAB & $oMyError.scriptline   & @CRLF & _
        "err.source is: "        & @TAB & $oMyError.source       & @CRLF & _
        "err.helpfile is: "    & @TAB & $oMyError.helpfile     & @CRLF & _
        "err.helpcontext is: "  & @TAB & $oMyError.helpcontext _
         )

  SetError(1); to check for after this function returns
Endfunc

That should exactly pinpoint the problem, including the line number in your script.

Regards,

-Sven

EDIT: Bad layout.

Edited by SvenP
Link to comment
Share on other sites

@svenp

Already had the Error handling function, but didn't return any errors.

Changed the au3.properties from 3.1.1.10 back to the original one from SciTe, after that there's no exit code, SciTe just says :

>AutoIT3.exe ended with rc:420

>Exit code: 0 Time: 0.698

The rcs for AutoIT3.exe are changing with every run of the script.

UPDATE :

I kind of solved the problem or at least found a workaround.

If I'm doing a select to find datasets I'm not able to use the ADOB.Recordset but instead I'm using the Connection.Execute method to get the data I want. When doing SQL Update or Insert, I'm still using the Recordset Object. Don't know what's the difference from Version 3.1.0.++ to 3.1.1.++ so that the Recordset Object doesn't work anymore.

Here's the changed code, which works :)

Func getDistinct()

    $adoCon = ObjCreate ("ADODB.Connection")
    $adoCon.Open ($DSN_Connect)
;$adoRs = ObjCreate ("ADODB.Recordset")
    $adoSQL = "SELECT DISTINCT Gerätetyp FROM [HW-Invent]"
    $adoRS = $adoCon.Execute ($adoSQL)
;$adoRs.CursorType = 2
;$adoRs.LockType = 3
;$adoRs.Open($adoSql, $adoCon)

    With $adoRs
    
        If .RecordCount Then
        
            While Not .EOF
                $cmboVal[2] = $cmboVal[2] & .Fields("Gerätetyp").Value & "|"
                .MoveNext
            WEnd
        
        EndIf
    
    EndWith

;$adoCon.Close
...

Thanks for your help .

Edited by dwerznec
Link to comment
Share on other sites

UPDATE :

I kind of solved the problem or at least found a workaround.

If I'm doing a select to find datasets I'm not able to use the ADOB.Recordset but instead I'm using the Connection.Execute method to get the data I want. When doing SQL Update or Insert, I'm still using the Recordset Object. Don't know what's the difference from Version 3.1.0.++ to 3.1.1.++ so that the Recordset Object doesn't work anymore.

....

Thanks for your help .

<{POST_SNAPBACK}>

I have made a lot of modifications in the COM code. For instance, all variables you are passing to a COM function are in V3.1.1 being passed by Reference instead of ByValue in V3.1.0.x.

There were also some bugs introduced in V3.1.1 (not deliberately !) and fixed lateron.

May I ask you to try your old code again after jpm has released the V3.1.1.11 beta version? Because I really want to get your old code also working.

Regards,

-Sven

Link to comment
Share on other sites

Sorry, but there's no change when using the Version 3.1.1.11.

The GUI crashes when I'm doing a simple Select Statement with the ADOB.Recordset.

When using the Connection.Execute, it's working.

When doing Insert or Update Statements, the GUI crashes as soon as the Connection Object is closed (see below)

$adoCon = ObjCreate ("ADODB.Connection")
            $adoCon.Open ($DSN_Connect)
            $adoRs = ObjCreate ("ADODB.Recordset")
            $adoSQL = "SELECT [HW-Invent].[Service-ID], [HW-Invent].Gerätetyp, [HW-Invent].Gerätename, " &_ 
                        "[HW-Invent].Beschreibung, [HW-Invent].Mitarbeiter, [HW-Invent].KST, KST.KSTV, [HW-Invent].Raum, " &_ 
                        "[HW-Invent].[IP-Adresse], [HW-Invent].[fest/statisch/variabel], [HW-Invent].Zweck, [HW-Invent].Bemerkung " &_ 
                        "FROM KST INNER JOIN [HW-Invent] ON KST.KST = [HW-Invent].KST " &_ 
                        "WHERE [HW-Invent].[Service-ID] LIKE '%" & StringTrimLeft($updRS[1], 6) & "%' " &_
                        "ORDER BY [HW-Invent].[Service-ID]"
            $adoRs.CursorType = 2
            $adoRs.LockType = 3
            $adoRs.Open($adoSql, $adoCon)

            With $adoRs
            
                If .RecordCount Then
                
                    While Not .EOF
                        .Fields("Gerätetyp").Value             = $updRS[2]
                        .Fields("Gerätename").Value                = $updRS[3]
                        .Fields("Beschreibung").Value           = $updRS[4]
                        .Fields("Mitarbeiter").Value            = $updRS[5]
                        .Fields("KST").Value                    = $updRS[6]
                        .Fields("Raum").Value                   = $updRS[8]
                        .Fields("IP-Adresse").Value             = $updRS[9]
                        .Fields("fest/statisch/variabel").Value = $updRS[10]
                        .Fields("Zweck").Value                  = $updRS[11]
                        .Fields("Bemerkung").Value              = $updRS[12]
                        
                        .Update                     
                        .MoveNext
                    WEnd
                                
                EndIf
        
            Endwith
            
            $adoCon.Close
;GUI crashes after $adoCon.Close, when not using $adoCon.Close everything is fine

When not Closing the Connection Object, everything is fine.

Are there any changes made, which do close the Connection itself without the need in doing so manually. When closing the Connection in 3.1.0.++ everything was ok, but in the new one it just crashes the whole script without any errorcodes or whatever (already tried debug:tracelines, but all the traces were ok)

Link to comment
Share on other sites

Sorry, but there's no change when using the Version 3.1.1.11.

The GUI crashes when I'm doing a simple Select Statement with the ADOB.Recordset.

When using the Connection.Execute, it's working.

When doing Insert or Update Statements, the GUI crashes as soon as the Connection Object is closed (see below)

..

When not Closing the Connection Object, everything is fine.

Are there any changes made, which do close the Connection itself without the need in doing so manually. When closing the Connection in 3.1.0.++ everything was ok, but in the new one it just crashes the whole script without any errorcodes or whatever (already tried debug:tracelines, but all the traces were ok)

<{POST_SNAPBACK}>

Hello dwerznec,

I have simulated the part of your script on my own computer, with a self-built acces database. And I can reproduce the exact problem.

It is definately a bug in the COM-code. Congratulations for finding this one ! :-)

The bug occures when you pass an Object-variable as an argument in a function in another object-variable (e.g. $adoRs.Open($adoSql, $adoCon) ), somehow the reference to the original Object-variable gets corrupted on return.

I have made a fix, but I need to test it first with all other scripts.

The fix will probably be included in beta version 3.1.1.12 .

Regards,

-Sven

Link to comment
Share on other sites

Sounds good, I'm looking forward for the bugfix.

I'll keep using the Connection.Execute to finish the design of the GUI, but as soon as this one is fixed, I'll be using the new version.

I like to close the connection because I'm doing quite a lot of SQL statements and i don't want to stress the SQL server too much.

Thanks for your fast help.

Link to comment
Share on other sites

Sounds good, I'm looking forward for the bugfix.

I'll keep using the Connection.Execute to finish the design of the GUI, but as soon as this one is fixed, I'll be using the new version.

I like to close the connection because I'm doing quite a lot of SQL statements and i don't want to stress the SQL server too much.

Thanks for your fast help.

<{POST_SNAPBACK}>

dwerznec,

AutoIt beta version 3.1.1.11 is out ! I hope this version helps.

Regards,

-Sven

Link to comment
Share on other sites

Great Job Guys,

Everything is back to normal, meaning my script is working the way it's supposed to be, even when using the ADOB.Recordset for SELECT, UPDATE or INSERT statements and I'm able to do a clean close of the connection/recordset without having my GUI crashed.

Thanks.

Link to comment
Share on other sites

Great Job Guys,

Everything is back to normal, meaning my script is working the way it's supposed to be, even when using the ADOB.Recordset for SELECT, UPDATE or INSERT statements and I'm able to do a clean close of the connection/recordset without having my GUI crashed.

Thanks.

<{POST_SNAPBACK}>

That's the exact reason why we are doing this kind of stuff: We like to receive compliments :-))

(that's a joke, ofcourse....Once we have infiltrated AutoIt.exe to all computers, we will activate our hidden backdoors and take over the whole world. Then we will demand everyone to give us a lot of money before we will 'release' their computers.)

:-)

-Sven

Edited by SvenP
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...