Sign in to follow this  
Followers 0
lsakizada

The script does not working after beta upgrade

29 posts in this topic

#1 ·  Posted (edited)

Hi, I have installed the lates beta and my old script does not working anymore.

Can you please let me know what cause the problem. I am unable to debug it.

If you know how to debug it then please drop me some lines ... Thanks for advance.

Here is my code:

#NoTrayIcon

#include <GUIConstants.au3>
#include <GUIListView.au3>

Global Const $WM_NOTIFY = 0x004E
Global Const $NM_FIRST = 0
Global Const $NM_LAST = (-99)
Global Const $NM_OUTOFMEMORY = ($NM_FIRST - 1)
Global Const $NM_CLICK = ($NM_FIRST - 2)
Global Const $NM_DBLCLK = ($NM_FIRST - 3)
Global Const $DebugIt = 1

Global Const $sql_str_1 = "SELECT FIRST 25 * From tctaudit Order By AuditId DESC;"
Global Const $sql_str_2 = "select * from tctauditproperties where auditpropid =" 
; ========================================
; Variables
; ========================================
Global Const $s_Title   = 'Cell - DB'
Global Const $s_Version = '0.1'
Global     $s_filenm  = ""

; ADO  QueryType                             ; Criteria
Global Const $i_ADOadSchemaCatalogs   = 1 ; table_catalog
Global Const $i_ADOadSchemaColumns     = 4 ; table_catalog - table_schema - table_name - column_name
Global Const $i_ADOadSchemaIndexes     = 12; table_catalog - table_schema - index_name - type - table_name
Global Const $i_ADOadSchemaProcedures   = 16; procedure_catalog - procedure_schema - procedure_name - procedure_type
Global Const $i_ADOadSchemaTables       = 20; table_catalog - table_schema - table_name - table_type
Global Const $i_ADOadSchemaProviderTypes = 22; data_type - best_match
Global Const $i_ADOadSchemaViews         = 23; table_catalog - table_schema - table_name
Global       $o_ADOconn, $o_ADOrs, $b_ADOiscon=0
; ADO cursortype and locktype
Global Const $i_adOpenDynamic   = 2
Global Const $i_adLockOptimistic = 3

; DSN 
Global Const $s_ODBCregUser   = "HKEY_CURRENT_USER\SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources"
Global Const $s_ODBCregSystem = "HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources"
Global Const $s_DSNHdr      = "DSN|Type|Description"
Global       $s_DSNfull, $s_DSNname, $s_DSNuid, $s_DSNpwd, $s_DSNdb, $i_DSNcount=0

; Listview headers
Global     $s_SchemaHdr  = "Schema information"
Global       $s_ResultHdr    = "Query result"
Global       $s_MonitorHdr   = "Monitor result" 

; ========================================
; COM object error handler
; ========================================
Global $i_ObjectDebug = 0                           ; 1 = show msgbox for every error
Global $s_ObjectErrorMsg                            ; Buffered message
$o_ComError = ObjEvent("AutoIt.Error","Object_Error") ; Install a custom error handler 

; ========================================
; GUI controls
; ========================================
$h_Gui = GuiCreate($s_Title, 704, 488, 490,360 ,BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
GUICtrlSetColor($h_Gui,0x0000ff)

; --- File Menu ---
$mn_file = GUICtrlCreateMenu ("&File")
GUICtrlSetResizing (-1,$GUI_DOCKMENUBAR)
$mn_open   = GUICtrlCreateMenuitem ("Open",$mn_file)
GUICtrlSetState(-1,$GUI_DISABLE)
$mn_recent = GUICtrlCreateMenu ("Recent Opened Files",$mn_file)
GUICtrlSetState(-1,$GUI_DISABLE)
$mn_saveas = GUICtrlCreateMenuitem ("Save as",$mn_file)
GUICtrlSetState(-1,$GUI_DISABLE)
$mn_exit   = GUICtrlCreateMenuitem ("E&xit",$mn_file)
GUICtrlCreateMenuitem ("",$mn_file,3); create a separator line
; --- View Menu ---
$mn_view = GUICtrlCreateMenu("View")
$mn_status = GUICtrlCreateMenuitem ("Statusbar",$mn_view)
GUICtrlSetState(-1,$GUI_CHECKED)
$mn_odbc = GUICtrlCreateMenuitem ("Informix ODBC messages",$mn_view)
; --- Help Menu ---
;$mn_help = GUICtrlCreateMenu ("Help")
;$mn_about = GUICtrlCreateMenuitem ("About",$mn_help)

; --- Statusbar ---
$sb_connect = GUICtrlCreateLabel('Disconnected',2,448,200,16,BitOr($SS_SIMPLE,$SS_SUNKEN))
GUICtrlSetResizing (-1,$GUI_DOCKSTATEBAR)
$sb_info = GUICtrlCreateLabel ('',205,448,495,16,BitOr($SS_SIMPLE,$SS_SUNKEN))
GUICtrlSetResizing (-1,$GUI_DOCKSTATEBAR)
; sb_progress - future use

; --- Tab ---
$tab=GUICtrlCreateTab (2,2, 700,440)
    GUICtrlSetResizing (-1,$GUI_DOCKBORDERS)

$tab_conn=GUICtrlCreateTabitem (" Connection ")
    $lst_dsn = GUICtrlCreateListView($s_DSNHdr, 20, 50, 550, 380, -1, BitOR( $LVS_EX_FULLROWSELECT , $LVS_EX_GRIDLINES))
    ODBCsources($lst_dsn,$s_ODBCregUser  , "USER"  )
    ODBCsources($lst_dsn,$s_ODBCregSystem, "SYSTEM")
    _GUICtrlListViewSetItemSelState ($lst_dsn, 0); select the first row

    GUICtrlCreateLabel("Optional:", 580, 50, 100, 20, -1, $WS_EX_TRANSPARENT )
    GUICtrlCreateLabel("Uid:", 580,  85, 30, 20, -1, $WS_EX_TRANSPARENT )
    GUICtrlCreateLabel("Pwd:", 580, 120, 30, 20, -1, $WS_EX_TRANSPARENT )
    GUICtrlCreateLabel("DB :", 580, 155, 30, 20, -1, $WS_EX_TRANSPARENT )
    $inp_uid   = GUICtrlCreateInput("informix", 610,  85, 80, 20)
    $inp_pwd   = GUICtrlCreateInput("informix", 610, 120, 80, 20, $ES_PASSWORD)
    $inp_db = GUICtrlCreateInput("celltick_db", 610, 155, 80, 20)
    $bt_conn   = GUICtrlCreateButton("&Connect"   , 600, 200, 80, 20, $BS_DEFPUSHBUTTON)
    $bt_discon = GUICtrlCreateButton("&Disconnect", 600, 240, 80, 20)
    GUICtrlSetState(-1, $GUI_DISABLE )


$tab_schema=GUICtrlCreateTabitem (" Schema ")
GUICtrlSetState($tab_schema,$GUI_DISABLE)
    $lst_schema = GUICtrlCreateListView($s_SchemaHdr, 20, 50, 550, 380)
;$bt_db   = GUICtrlCreateButton("&Databases", 600,  70, 80, 20)
    $bt_tbl  = GUICtrlCreateButton("&Tables"   , 600, 110, 80, 20)
    $bt_col  = GUICtrlCreateButton("&Columns"  , 600, 150, 80, 20)
    $bt_scopy   = GUICtrlCreateButton("&Clipboard", 600, 210, 80, 20)
    $bt_ssaveas = GUICtrlCreateButton("Save &as"  , 600, 250, 80, 20)

$tab_query=GUICtrlCreateTabitem (" Query ")
GUICtrlSetState($tab_query,$GUI_DISABLE)
    $ed_qry  = GUICtrlCreateEdit("", 20, 50, 550, 380)
    $bt_run  = GUICtrlCreateButton("&Run"   , 600,  70, 80, 20)
    $bt_clr  = GUICtrlCreateButton("Cl&ear"  , 600, 110, 80, 20)
    $bt_open    = GUICtrlCreateButton("&Open"   , 600, 180, 80, 20)
    $bt_saveas  = GUICtrlCreateButton("Save &as SQL", 600, 220, 80, 20)

$tab_result=GUICtrlCreateTabitem (" Result ")
GUICtrlSetState($tab_result,$GUI_DISABLE)
    $lst_result = GUICtrlCreateListView($s_ResultHdr, 20, 50, 550, 350)
    $bt_new  = GUICtrlCreateButton("&New query"  , 600,  70, 80, 20)
;$bt_rcopy   = GUICtrlCreateButton("&Clipboard"  , 600, 140, 80, 20)
;$bt_rsaveas = GUICtrlCreateButton("Save &as"   , 600, 180, 80, 20)
GUICtrlCreateTabitem (""); end of Tab control

; Monitor tab
$tab_monitor=GUICtrlCreateTabitem (" Monitor AT ")
GUICtrlSetState($tab_monitor,$GUI_DISABLE)
    $inp_rows= GUICtrlCreateInput(25,600, 80, 80, 20)
    $lab_rows = GUICtrlCreateLabel("Rows: ",600, 60, 80, 20)
    $lst_monitor = GUICtrlCreateListView($s_MonitorHdr, 20, 50, 550, 150)
    $lst_monitor1 = GUICtrlCreateListView($s_MonitorHdr, 20, 270, 550, 150)
    $bt_monitorstart   = GUICtrlCreateButton("&Start"  , 600, 210, 80, 20)
    $b_size = ControlGetPos("", "", $lst_monitor)
    $lab_sql2 = GUICtrlCreateLabel($sql_str_1, 20, $b_size[1]- 15, 550, 150)
    $c_size = ControlGetPos("", "", $lst_monitor1)
    $lab_sql2 = GUICtrlCreateLabel($sql_str_2, 20, $c_size[1]- 15, 550, 150)
    
    
GUICtrlCreateTabitem (""); end of Tab control

; --- Show Gui ---
GUICtrlSetState($lst_dsn,$GUI_FOCUS); Focus on dsn list
GUISetState (@SW_SHOW,$h_Gui)               

onload()
While 1
    $msg = GUIGetMsg()
    if $msg <> 0 then
        Select
        Case $msg = $GUI_EVENT_CLOSE or $msg=$mn_exit
            ExitLoop
        Case $msg = $mn_open OR $msg = $bt_open
            SQLopen()
          Case $msg = $mn_saveas OR $msg = $bt_saveas
            SQLsave()
        Case $msg = $bt_monitorstart
            GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events")
            
             if ValidateFields(GUICtrlRead($inp_rows)) Then 
                 
    ;   $sql_str_1_1 = "SELECT FIRST "& GUICtrlRead($inp_rows) & "  * From tctaudit Order By AuditId DESC;" 
    ;   $b_size = ControlGetPos("", "", $lst_monitor)
    ;   $lab_sql2 = GUICtrlCreateLabel($sql_str_1_1, 20, $b_size[1]- 15, 550, 150)
                
                
                
        ;while 1
                ODBCMonitorQuery("SELECT FIRST "& GUICtrlRead($inp_rows)&" * From tctaudit Order By AuditId DESC; ")
        ;sleep(1000)
              ;WEnd
            EndIf
            
            
            
        Case $msg = $mn_status
            If BitAnd(GUICtrlRead($mn_status),$GUI_CHECKED) = $GUI_CHECKED Then
                GUICtrlSetState($mn_status ,$GUI_UNCHECKED)
                GUICtrlSetState($sb_connect,$GUI_HIDE)
                GUICtrlSetState($sb_info   ,$GUI_HIDE)
            Else
                GUICtrlSetState($mn_status ,$GUI_CHECKED)
                GUICtrlSetState($sb_connect,$GUI_SHOW)
                GUICtrlSetState($sb_info   ,$GUI_SHOW)
            EndIf
        Case $msg = $mn_odbc
            If BitAnd(GUICtrlRead($mn_odbc),$GUI_CHECKED) = $GUI_CHECKED Then
                GUICtrlSetState($mn_odbc ,$GUI_UNCHECKED)
                $i_ObjectDebug = 0
            Else
                GUICtrlSetState($mn_odbc ,$GUI_CHECKED)
                $i_ObjectDebug = 1
            EndIf
;Case $msg = $mn_about
;   About()
        Case $msg = $bt_conn
            ODBCconnect()
        Case $msg = $bt_discon
            $o_ADOconn.Close
            GUICtrlSetState($bt_conn    , $GUI_ENABLE  )
            GUICtrlSetState($bt_discon  , $GUI_DISABLE )
            GUICtrlSetState($mn_open    , $GUI_DISABLE )
            GUICtrlSetState($mn_recent  , $GUI_DISABLE )
            GUICtrlSetState($mn_saveas  , $GUI_DISABLE )
            GUICtrlSetState($tab_schema , $GUI_DISABLE )
            GUICtrlSetState($tab_query  , $GUI_DISABLE )
            GUICtrlSetState($tab_result , $GUI_DISABLE )
            
            GUICtrlSetState($bt_tbl  , $GUI_DISABLE )
            GUICtrlSetState($bt_col  , $GUI_DISABLE )
            GUICtrlSetState($bt_scopy  , $GUI_DISABLE )
            GUICtrlSetState($bt_ssaveas  , $GUI_DISABLE )
            $b_ADOiscon=0
            StatusBar("Disconnected")
;Case $msg = $bt_db
;   ODBCschema($i_ADOadSchemaCatalogs)
        Case $msg = $bt_tbl
            ODBCschema($i_ADOadSchemaTables)
        Case $msg = $bt_col
            ODBCschema($i_ADOadSchemaColumns)
        Case $msg = $bt_scopy
            SAVElist($lst_schema,$s_SchemaHdr)      ; clipboard copy
        Case $msg = $bt_ssaveas
            SAVElist($lst_result,$s_ResultHdr, "file"); save schema to file
        Case $msg = $bt_run
            ODBCquery(GUICtrlRead($ed_qry))
        Case $msg = $bt_clr
            GUICtrlSetData($ed_qry, "" )            ; clear data
            GUICtrlSetState($lst_result,$GUI_FOCUS)
        Case $msg = $bt_new
            GUICtrlSetState($tab_query, $GUI_SHOW ) ; show query tab
            GUICtrlSetState($ed_qry, $GUI_FOCUS )   ; select edit field
;Case $msg = $bt_rcopy
;   SAVElist($lst_result,$s_ResultHdr)      ; clipboard copy
;Case $msg = $bt_rsaveas
;   SAVEList($lst_result,$s_ResultHdr, "file"); save result to file
        Case $msg = $tab_query
            GUICtrlSetState($tab_query, $GUI_SHOW  ); show query tab
            GUICtrlSetState($ed_qry   , $GUI_FOCUS ); select edit field
      EndSelect
    EndIf
WEnd
GUIDelete()
Exit

Func SAVElist($l_list, $s_hdr="", $filenm="")
    Local $a_indices = _GUICtrlListViewGetSelectedIndices($l_list,1)
    If(IsArray($a_indices))Then
        Local $i, $buf
        $buf=$s_hdr & @LF
        For $i = 1 To $a_indices[0]
            $buf &= _GUICtrlListViewGetItemText ($l_list, $a_indices[$i], -1)  & @LF 
        Next
        if $filenm <> "" Then
            $filenm =  FileSaveDialog( "Save as...", '.', "All files (*.*)", 3)
            If @error <> 1 Then 
                FileWrite($filenm,$buf)
                GUICtrlSetData($sb_info, "Selected rows saved to file")
            EndIf
        Else
            ClipPut($buf)
            GUICtrlSetData($sb_info, "Selected rows copied to clipboard")
        Endif
    Else
        GUICtrlSetData($sb_info, "Not Items Selected")
    EndIf
EndFunc

Func SQLopen()
    if $b_ADOiscon = 1 then
        $s_filenm = FileOpenDialog("Choose file...",'.',"SQLfiles (*.sql)|All (*.*)")
        If @error <> 1 Then 
            GUICtrlCreateMenuitem ($s_filenm,$mn_recent)
            GUICtrlSetData($ed_qry,FileRead($s_filenm,4096))
        Endif
    Endif
EndFunc

Func SQLsave()
    if $b_ADOiscon = 1 then
        $s_filenm =  FileSaveDialog( "Save as...", $s_filenm, "SQLfiles (*.sql)", 3)
        If @error <> 1 Then 
            FileWrite($s_filenm,GUICtrlRead($ed_qry))
        Endif
    Endif
EndFunc


Func ODBCsources($h_controlID, $s_RegEntry, $s_Type)
    Local $s_List, $i_dsncount, $s_VarNm, $s_Value, $i
    $i = 1
    $s_VarNm = RegEnumVal($s_RegEntry,  $i)
    $s_Value = RegRead($s_RegEntry, $s_Varnm)
    While $s_VarNm <> ""
        $s_VarNm = RegEnumVal($s_RegEntry,  $i)
        $s_Value = RegRead($s_RegEntry, $s_Varnm)
        If $s_Varnm <> "" Then
            GUICtrlCreateListViewItem($s_VarNm & "|" & $s_Type & "|" & $s_Value, $h_controlID)
            $i += 1
            $i_DSNcount += 1
        EndIf
    Wend
EndFunc

Func ODBCconnect()
    $dsnarray = StringSplit((GUICtrlRead(GUICtrlRead($lst_dsn), 2)), "|"); retrieve selected row
    if $dsnarray[1] <> "" Then
        $s_DSNName = $dsnarray[1]
        $s_DSNuid  = GUICtrlRead($inp_uid)
        $s_DSNpwd  = GUICtrlRead($inp_pwd)
        $s_DSNdb   = GUICtrlRead($inp_db)
        $s_DSNfull = "DSN=" & $s_DSNName & ";"
        if $s_DSNuid <> "" then $s_DSNfull &= "Uid=" & $s_DSNuid & ";"
        if $s_DSNpwd <> "" then $s_DSNfull &= "Pwd=" & $s_DSNpwd & ";"
        if $s_DSNdb  <> "" then $s_DSNfull &= "database=" & $s_DSNdb & ";"
        $o_ADOconn = ObjCreate ("ADODB.Connection")
        $o_ADOconn.Open ($s_DSNfull)
        if @error then 
            msgbox(64, "Connection error", "Error connecting to database DSN=["&$s_DSNfull &"]")
        else
            GUICtrlSetState($bt_conn  , $GUI_DISABLE )
            GUICtrlSetState($bt_discon, $GUI_ENABLE  )
            Statusbar("","Connected to "&$s_DSNName  )
            GUICtrlSetState($tab_schema , $GUI_ENABLE )
            GUICtrlSetState($tab_query  , $GUI_ENABLE )
            GUICtrlSetState($tab_result , $GUI_ENABLE )
            GUICtrlSetState($tab_query  , $GUI_SHOW   ) ; show query tab
            GUICtrlSetState($ed_qry  , $GUI_FOCUS  )    ; select edit field
            GUICtrlSetState($mn_open    , $GUI_ENABLE )
            GUICtrlSetState($mn_recent  , $GUI_ENABLE )
            GUICtrlSetState($mn_saveas  , $GUI_ENABLE )
            
            GUICtrlSetState($bt_tbl  , $GUI_ENABLE )
            GUICtrlSetState($bt_col  , $GUI_ENABLE )
            GUICtrlSetState($bt_scopy  , $GUI_ENABLE )
            GUICtrlSetState($bt_ssaveas  , $GUI_ENABLE )
            
            $b_ADOiscon=1
        Endif   
    Endif
EndFunc
        
Func StatusBar($info, $conn="")
   if $conn <> "" Then  GUICtrlSetData($sb_connect, $conn)
   if $info <> "" Then  GUICtrlSetData($sb_info   , $info)
EndFunc
        
        
Func ODBCquery($s_Qry)
    Local $cmboVal, $n
    StatusBar("Starting query...")

    $o_ADOrs = ObjCreate ("ADODB.Recordset")
    $o_ADOrs.CursorType = $i_adOpenDynamic
    $o_ADOrs.LockType = $i_adLockOptimistic
    $o_ADOrs.Open ($s_Qry, $o_ADOconn)
    if @error Then
        msgbox(64,"Info","Error in query !",2);
        StatusBar("Error in query !");
        Return
    Endif
        
    GUICtrlSetState($tab_result, $GUI_SHOW )    ; show result tab
    GuiSwitch($h_Gui,$tab_result)
    $a_size = ControlGetPos("", "", $lst_schema); retrieve controls current postion and size
    GuiCtrlDelete($lst_result)
    With $o_ADOrs
      $s_ResultHdr=""                           ; Get information about Fields collection
      For $n = 0 To .Fields.Count - 1
         $s_ResultHdr &= .Fields($n).Name & "|"
      Next
      $lst_result = GUICtrlCreateListView($s_ResultHdr, $a_size[0], $a_size[1], $a_size[2], $a_size[3],  $LVS_REPORT, BitOR( $LVS_EX_FULLROWSELECT , $LVS_EX_GRIDLINES) )
      GUICtrlSetResizing (-1,$GUI_DOCKAUTO)

      If .RecordCount Then
         While Not .EOF
            $cmboVal = ""
            For $n = 0 To .Fields.Count - 1
                $cmboVal = $cmboVal & .Fields($n).Value & "|"
            Next
            $cmboVal = StringTrimRight($cmboVal, 1)
            GUICtrlCreateListViewItem($cmboVal, $lst_result)
            .MoveNext
         WEnd
      EndIf
   EndWith
   GUICtrlCreateTabItem("")
   GUICtrlSetState($lst_result,$GUI_FOCUS)
   StatusBar("Done")
   GUISetState (@SW_SHOW,$h_Gui)
EndFunc


Func ODBCschema($i_qrytype)
    Local $n
    GUICtrlSetState($tab_schema, $GUI_SHOW )    ; show result tab
    GuiSwitch($h_Gui,$tab_schema)

    $a_size = ControlGetPos("", "", $lst_schema)      ; retrieve controls current postion and size
    GuiCtrlDelete($lst_schema)

    StatusBar("Retrieving schema..")
    $o_ADOrs = $o_ADOconn.OpenSchema ($i_qrytype)
    
    With $o_ADOrs
        $s_SchemaHdr=""                         ; Get information about Fields collection
        For $n = 0 To .Fields.Count - 1
            $s_SchemaHdr &= .Fields($n).Name & "|"
        Next
        $lst_schema = GUICtrlCreateListView($s_SchemaHdr, $a_size[0], $a_size[1], $a_size[2], $a_size[3],  $LVS_REPORT, BitOR( $LVS_EX_FULLROWSELECT , $LVS_EX_GRIDLINES) )
          GUICtrlSetResizing (-1,$GUI_DOCKAUTO)
        While Not .EOF
            $cmboVal = ""
            For $n = 0 To .Fields.Count - 1
               $cmboVal &= .Fields($n).Value & "|"
            Next
            $cmboVal = StringTrimRight($cmboVal, 1)
            GUICtrlCreateListViewItem($cmboVal, $lst_schema)
            .MoveNext
        WEnd
   EndWith
   GUICtrlCreateTabItem("")
   GUICtrlSetState($lst_schema,$GUI_FOCUS)
   StatusBar("Done")
   GUISetState (@SW_SHOW,$h_Gui)
EndFunc


; ========================================
; GUI - About
; ========================================
Func About()
;   $gui_About = GuiCreate('About', 315, 200, -1, -1, BitOr($WS_CAPTION, $WS_SYSMENU), -1, $h_Gui)
;   GUICtrlCreateIcon ("shell32.dll", 175, 5,8)
;   GuiCtrlCreateLabel($s_Title & ' v' & $s_Version & '        -           The Simple Query Utility' & @LF &_
;                 @LF &_
;                 'This application is a simple program for easily retrieving  ' &_
;                 'information from a database using ODBC. ' & @LF &_
;                 @LF &_
;                 'It was written in AutoIt3 script by Hans Harder.' & @LF &_
;                 @LF &_
;                  ' ' , 45, 15, 290, 140)
;   $lb_Ab_VisitSite     = _GuiCtrlCreateHyperlink('Visit the AutoIt Website', 5, 155, 165, 15, 0x0000ff, 'http://www.autoitscript.com')
;   $lb_Ab_ContactAuthor = _GuiCtrlCreateHyperlink('Contact Hans Harder', 5, 175, 165, 15, 0x0000ff, 'mailto:hans@atabas.org')
;   $bt_Ab_Close         = GuiCtrlCreateButton('&Close', 225, 165, 75, 25)
;   GuiSetState(@SW_SHOW, $gui_About)

;   While 1
;       $msg = GUIGetMsg()
;       if $msg <> 0 then
;          Select
;           Case $msg = $lb_Ab_VisitSite
;               _Start('http://www.autoitscript.com')
;           Case $msg = $lb_Ab_ContactAuthor
;               _Start('"mailto:hans@atbas.org?Subject=AutoIt3 QDBCquery Application"')
;           Case $msg = $GUI_EVENT_CLOSE Or $msg = $bt_Ab_Close
;               ExitLoop
;           EndSelect
;       Endif
;   WEnd
;   GuiSetState(@SW_HIDE, $gui_About)
;   GuiDelete($gui_About)
EndFunc

;===============================================================================
;
; Function Name:    _GuiCtrlCreateHyperlink()
; Description:    Creates a label that acts as a hyperlink
;
; Parameter(s):     $s_Text    - Label text
;                           $i_Left       - Label left coord
;                           [$i_Top]      - Label top coord
;                           [$i_Width]    - Label width
;                           [$i_Height]   - Label height
;                           [$i_Color]    - Text Color
;                           [$s_ToolTip]  - Hyperlink ToolTip
;                           [$i_Style]    - Label style
;                           [$i_ExStyle]  - Label extended style
;
; Requirement(s):   None
; Return Value(s):  Control ID
;
; Author(s):        Saunders <krawlie@hotmail.com>
;
;===============================================================================
;   $lb_Ab_VisitSite     = _GuiCtrlCreateHyperlink('Visit the AutoIt Website', 5, 155, 165, 15, 0x0000ff, 'http://www.autoitscript.com')
Func _GuiCtrlCreateHyperlink($S_TEXT, $I_LEFT, $I_TOP, _
        $I_WIDTH = -1, $I_HEIGHT = -1, $I_COLOR = 0x0000ff, $S_TOOLTIP = '', $I_STYLE = -1, $I_EXSTYLE = -1)
    Local $I_CTRLID
    $I_CTRLID = GUICtrlCreateLabel($S_TEXT, $I_LEFT, $I_TOP, $I_WIDTH, $I_HEIGHT, $I_STYLE, $I_EXSTYLE)
    If $I_CTRLID <> 0 Then
        GUICtrlSetFont($I_CTRLID, -1, -1, 4)
        GUICtrlSetColor($I_CTRLID, $I_COLOR)
        GUICtrlSetCursor($I_CTRLID, 0)
    EndIf
    Return $I_CTRLID
EndFunc;==>_GuiCtrlCreateHyperlink

Func _Start($s_StartPath)
    If @OSType = 'WIN32_NT' Then
        $s_StartStr = @ComSpec & ' /c start "" '
    Else
        $s_StartStr = @ComSpec & ' /c start '
    EndIf
    Run($s_StartStr & $s_StartPath, '', @SW_HIDE)
EndFunc

Func Object_Error() 
   $HexNumber=hex($o_ComError.number,8) 
   $s_ObjectError="COM Error = " & $HexNumber & @CRLF & _
                  "Windescription is: " & $o_ComError.windescription 
   if $i_ObjectDebug <> 0 Then msgbox(64, "Database error", "Database Error : "& $s_ObjectError &"")
   SetError(1); something to check for when this function returns 
Endfunc

Func onload()
   GUICtrlSetState($bt_tbl  , $GUI_DISABLE )
   GUICtrlSetState($bt_col  , $GUI_DISABLE )
   GUICtrlSetState($bt_scopy  , $GUI_DISABLE )
   GUICtrlSetState($bt_ssaveas  , $GUI_DISABLE )
   
EndFunc

Func ODBCMonitorQuery($s_Qry)
    Local $cmboVal, $n
    GUICtrlSetState($lst_monitor , $GUI_DISABLE )
    StatusBar("Starting query...")
GUISetState (81,$lst_monitor1)
    $o_ADOrs = ObjCreate ("ADODB.Recordset")
    $o_ADOrs.CursorType = $i_adOpenDynamic
    $o_ADOrs.LockType = $i_adLockOptimistic
    $o_ADOrs.Open ($s_Qry, $o_ADOconn)
    if @error Then
        msgbox(64,"Info","Error occured !",2);
        StatusBar("Error occured!");
        Return
    Endif
        
    GUICtrlSetState($tab_monitor, $GUI_SHOW )        
    GuiSwitch($h_Gui,$tab_monitor)
    $a_size = ControlGetPos("", "", $lst_schema)     
    GuiCtrlDelete($lst_monitor)
    With $o_ADOrs
      $s_MonitorHdr=""                               
      For $n = 0 To .Fields.Count - 1
         $s_MonitorHdr &= .Fields($n).Name & "|"
      Next
      $lst_monitor = GUICtrlCreateListView($s_MonitorHdr, $a_size[0], $a_size[1], $a_size[2], $a_size[3]/2,  $LVS_REPORT, BitOR( $LVS_EX_FULLROWSELECT , $LVS_EX_GRIDLINES) )
      
      GUICtrlSetResizing (-1,$GUI_DOCKAUTO)

      If .RecordCount Then
        While Not .EOF
                    $cmboVal = ""
                    For $n = 0 To .Fields.Count - 1
                        $cmboVal = $cmboVal & .Fields($n).Value & "|"
                    Next
                    $cmboVal = StringTrimRight($cmboVal, 1)
                    GUICtrlCreateListViewItem($cmboVal, $lst_monitor)
                    .MoveNext
        WEnd
      EndIf
   EndWith
   GUICtrlCreateTabItem("")
   GUICtrlSetState($lst_monitor,$GUI_FOCUS)
   StatusBar("Done")
  GUICtrlSetState($lst_monitor , $GUI_ENABLE)
   GUISetState (@SW_SHOW,$h_Gui)

EndFunc


Func ODBCMonitorQuery1($s_Qry)
    Local $cmboVal, $n
    StatusBar("Starting query...")
    
    $o_ADOrs = ObjCreate ("ADODB.Recordset")
    $o_ADOrs.CursorType = $i_adOpenDynamic
    $o_ADOrs.LockType = $i_adLockOptimistic
    $o_ADOrs.Open ($s_Qry, $o_ADOconn)
    if @error Then
        msgbox(64,"Info","Error occured !",2);
        StatusBar("Error occured!");
        Return
    Endif
        
    GUICtrlSetState($tab_monitor, $GUI_SHOW )        
    GuiSwitch($h_Gui,$tab_monitor)
    $a_size = ControlGetPos("", "", $lst_schema)     
    GuiCtrlDelete($lst_monitor1)
    With $o_ADOrs
      $s_MonitorHdr=""                               
      For $n = 0 To .Fields.Count - 1
         $s_MonitorHdr &= .Fields($n).Name & "|"
     Next
;msgBox(0,0, $a_size[0] & " " & $a_size[1] & " " & $a_size[2] & " " & $a_size[3])
;$b_size = ControlGetPos("", "", $lst_monitor)
;MsgBox(0,$b_size[1],$b_size[1])
      $lst_monitor1 = GUICtrlCreateListView($s_MonitorHdr, $a_size[0], ($a_size[1] + $a_size[3]/3) + $a_size[3]/3, $a_size[2], $a_size[3]/3,  $LVS_REPORT, BitOR( $LVS_EX_FULLROWSELECT , $LVS_EX_GRIDLINES) )
      GUICtrlSetResizing (-1,$GUI_DOCKAUTO)
        
      If .RecordCount Then
        While Not .EOF
                    $cmboVal = ""
                    For $n = 0 To .Fields.Count - 1
                        $cmboVal = $cmboVal & .Fields($n).Value & "|"
                    Next
                    $cmboVal = StringTrimRight($cmboVal, 1)
                    GUICtrlCreateListViewItem($cmboVal, $lst_monitor1)
                    .MoveNext
        WEnd
      EndIf
   EndWith
   GUICtrlCreateTabItem("")
   GUICtrlSetState($lst_monitor1,$GUI_FOCUS)
   StatusBar("Done")
   GUISetState (@SW_SHOW,$h_Gui)

EndFunc

Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam)
    #forceref $hWndGUI, $MsgID, $wParam
    Local $tagNMHDR, $event, $hwndFrom, $code
    $tagNMHDR = DllStructCreate("int;int;int", $lParam)
    If @error Then Return
    $event = DllStructGetData($tagNMHDR, 3)
    Select
        Case $wParam = $lst_monitor
            Select
                Case $event = $NM_CLICK
                    ListView_Click ("lst_monitor")
                Case $event = $NM_DBLCLK
                    ListView_DoubleClick ("lst_monitor")
            EndSelect
;Case $wParam = $lst_monitor1
;   Select
;       Case $event = $NM_CLICK
;           ListView_Click ("lst_monitor1")
;       Case $event = $NM_DBLCLK
      ;     ListView_DoubleClick ("lst_monitor1")
;   EndSelect
    EndSelect
    
    $tagNMHDR = 0
    $event = 0
    $lParam = 0
EndFunc;==>WM_Notify_Events

Func ListView_Click($monitor)
 Local $arr
            Select
                Case $monitor = "lst_monitor"
                
                    $arr = StringSplit (_GUICtrlListViewGetItemText ($lst_monitor, _GUICtrlListViewGetSelectedIndices($lst_monitor)),"|")
                    ODBCMonitorQuery1("select * from tctauditproperties where auditpropid =" & $arr[2])
                                    
            ;$sql_str_2_2 = "select * from tctauditproperties where auditpropid =" & $arr[2]
                    
            ;$c_size = ControlGetPos("", "", $lst_monitor1)
            ;$lab_sql2 = GUICtrlCreateLabel($sql_str_2_2, 20, $c_size[1]- 15, 550, 150)
                Case $monitor = "lst_monitor1"
                ;   MsgBox(0,"Data Row", _GUICtrlListViewGetItemText ($lst_monitor1, _GUICtrlListViewGetSelectedIndices($lst_monitor1)))
            EndSelect
EndFunc  

Func ListView_DoubleClick($monitor)
            Select
                Case $monitor = "lst_monitor"
                    MsgBox(64,"Data Row", _GUICtrlListViewGetItemText ($lst_monitor, _GUICtrlListViewGetSelectedIndices($lst_monitor)),10)
                Case $monitor = "lst_monitor1"
            ;   MsgBox(0,"Data Row", _GUICtrlListViewGetItemText ($lst_monitor1, _GUICtrlListViewGetSelectedIndices($lst_monitor1)))
            EndSelect
EndFunc 

Func ValidateFields( $Eve)
        
    $Eve =int($Eve)
   if $Eve = 0 Then
        MsgBox(0,"Error","Number of rows must be numeric.")
        return 0
    endif
    if $Eve < 0 Then
        MsgBox(0,"Error","The number of rows must be a positive number greater then 1")
        return 0
    endif

    If GUICtrlRead ($inp_rows) = "" Then
        
        
            MsgBox(0,"Error","You must select at least one row")
        return 0
    endif
    return 1
EndFunc
Edited by lsakizada

Be Green Now or Never (BGNN)!

Share this post


Link to post
Share on other sites



Use a codebox with autoit tags like this

#NoTrayIcon

#include <GUIConstants.au3>
#include <GUIListView.au3>

Global Const $WM_NOTIFY = 0x004E
Global Const $NM_FIRST = 0
Global Const $NM_LAST = (-99)
Global Const $NM_OUTOFMEMORY = ($NM_FIRST - 1)
Global Const $NM_CLICK = ($NM_FIRST - 2)
Global Const $NM_DBLCLK = ($NM_FIRST - 3)
Global Const $DebugIt = 1

Global Const $sql_str_1 = "SELECT FIRST 25 * From tctaudit Order By AuditId DESC;"
Global Const $sql_str_2 = "select * from tctauditproperties where auditpropid ="
; ========================================
; Variables
; ========================================
Global Const $s_Title = 'CellTick - DB'
Global Const $s_Version = '0.1'
Global $s_filenm = ""

; ADO QueryType ; Criteria
Global Const $i_ADOadSchemaCatalogs = 1 ; table_catalog
Global Const $i_ADOadSchemaColumns = 4 ; table_catalog - table_schema - table_name - column_name
Global Const $i_ADOadSchemaIndexes = 12 ; table_catalog - table_schema - index_name - type - table_name
Global Const $i_ADOadSchemaProcedures = 16 ; procedure_catalog - procedure_schema - procedure_name - procedure_type
Global Const $i_ADOadSchemaTables = 20 ; table_catalog - table_schema - table_name - table_type
Global Const $i_ADOadSchemaProviderTypes = 22 ; data_type - best_match
Global Const $i_ADOadSchemaViews = 23 ; table_catalog - table_schema - table_name
Global $o_ADOconn, $o_ADOrs, $b_ADOiscon = 0
; ADO cursortype and locktype
Global Const $i_adOpenDynamic = 2
Global Const $i_adLockOptimistic = 3

; DSN
Global Const $s_ODBCregUser = "HKEY_CURRENT_USER\SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources"
Global Const $s_ODBCregSystem = "HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources"
Global Const $s_DSNHdr = "DSN|Type|Description"
Global $s_DSNfull, $s_DSNname, $s_DSNuid, $s_DSNpwd, $s_DSNdb, $i_DSNcount = 0

; Listview headers
Global $s_SchemaHdr = "Schema information"
Global $s_ResultHdr = "Query result"
Global $s_MonitorHdr = "Monitor result"

; ========================================
; COM object error handler
; ========================================
Global $i_ObjectDebug = 0 ; 1 = show msgbox for every error
Global $s_ObjectErrorMsg ; Buffered message
$o_ComError = ObjEvent("AutoIt.Error", "Object_Error") ; Install a custom error handler

; ========================================
; GUI controls
; ========================================
$h_Gui = GUICreate($s_Title, 704, 488, 490, 360, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
GUICtrlSetColor($h_Gui, 0x0000ff)

; --- File Menu ---
$mn_file = GUICtrlCreateMenu("&File")
GUICtrlSetResizing(-1, $GUI_DOCKMENUBAR)
$mn_open = GUICtrlCreateMenuitem("Open", $mn_file)
GUICtrlSetState(-1, $GUI_DISABLE)
$mn_recent = GUICtrlCreateMenu("Recent Opened Files", $mn_file)
GUICtrlSetState(-1, $GUI_DISABLE)
$mn_saveas = GUICtrlCreateMenuitem("Save as", $mn_file)
GUICtrlSetState(-1, $GUI_DISABLE)
$mn_exit = GUICtrlCreateMenuitem("E&xit", $mn_file)
GUICtrlCreateMenuitem("", $mn_file, 3) ; create a separator line
; --- View Menu ---
$mn_view = GUICtrlCreateMenu("View")
$mn_status = GUICtrlCreateMenuitem("Statusbar", $mn_view)
GUICtrlSetState(-1, $GUI_CHECKED)
$mn_odbc = GUICtrlCreateMenuitem("Informix ODBC messages", $mn_view)
; --- Help Menu ---
;$mn_help = GUICtrlCreateMenu ("Help")
;$mn_about = GUICtrlCreateMenuitem ("About",$mn_help)

; --- Statusbar ---
$sb_connect = GUICtrlCreateLabel('Disconnected', 2, 448, 200, 16, BitOR($SS_SIMPLE, $SS_SUNKEN))
GUICtrlSetResizing(-1, $GUI_DOCKSTATEBAR)
$sb_info = GUICtrlCreateLabel('', 205, 448, 495, 16, BitOR($SS_SIMPLE, $SS_SUNKEN))
GUICtrlSetResizing(-1, $GUI_DOCKSTATEBAR)
; sb_progress - future use

; --- Tab ---
$tab = GUICtrlCreateTab(2, 2, 700, 440)
GUICtrlSetResizing(-1, $GUI_DOCKBORDERS)

$tab_conn = GUICtrlCreateTabItem(" Connection ")
$lst_dsn = GUICtrlCreateListView($s_DSNHdr, 20, 50, 550, 380, -1, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES))
ODBCsources($lst_dsn, $s_ODBCregUser, "USER")
ODBCsources($lst_dsn, $s_ODBCregSystem, "SYSTEM")
_GUICtrlListViewSetItemSelState($lst_dsn, 0) ; select the first row

GUICtrlCreateLabel("Optional:", 580, 50, 100, 20, -1, $WS_EX_TRANSPARENT)
GUICtrlCreateLabel("Uid:", 580, 85, 30, 20, -1, $WS_EX_TRANSPARENT)
GUICtrlCreateLabel("Pwd:", 580, 120, 30, 20, -1, $WS_EX_TRANSPARENT)
GUICtrlCreateLabel("DB :", 580, 155, 30, 20, -1, $WS_EX_TRANSPARENT)
$inp_uid = GUICtrlCreateInput("informix", 610, 85, 80, 20)
$inp_pwd = GUICtrlCreateInput("informix", 610, 120, 80, 20, $ES_PASSWORD)
$inp_db = GUICtrlCreateInput("celltick_db", 610, 155, 80, 20)
$bt_conn = GUICtrlCreateButton("&Connect", 600, 200, 80, 20, $BS_DEFPUSHBUTTON)
$bt_discon = GUICtrlCreateButton("&Disconnect", 600, 240, 80, 20)
GUICtrlSetState(-1, $GUI_DISABLE)


$tab_schema = GUICtrlCreateTabItem(" Schema ")
GUICtrlSetState($tab_schema, $GUI_DISABLE)
$lst_schema = GUICtrlCreateListView($s_SchemaHdr, 20, 50, 550, 380)
;$bt_db = GUICtrlCreateButton("&Databases", 600, 70, 80, 20)
$bt_tbl = GUICtrlCreateButton("&Tables", 600, 110, 80, 20)
$bt_col = GUICtrlCreateButton("&Columns", 600, 150, 80, 20)
$bt_scopy = GUICtrlCreateButton("&Clipboard", 600, 210, 80, 20)
$bt_ssaveas = GUICtrlCreateButton("Save &as", 600, 250, 80, 20)

$tab_query = GUICtrlCreateTabItem(" Query ")
GUICtrlSetState($tab_query, $GUI_DISABLE)
$ed_qry = GUICtrlCreateEdit("", 20, 50, 550, 380)
$bt_run = GUICtrlCreateButton("&Run", 600, 70, 80, 20)
$bt_clr = GUICtrlCreateButton("Cl&ear", 600, 110, 80, 20)
$bt_open = GUICtrlCreateButton("&Open", 600, 180, 80, 20)
$bt_saveas = GUICtrlCreateButton("Save &as SQL", 600, 220, 80, 20)

$tab_result = GUICtrlCreateTabItem(" Result ")
GUICtrlSetState($tab_result, $GUI_DISABLE)
$lst_result = GUICtrlCreateListView($s_ResultHdr, 20, 50, 550, 350)
$bt_new = GUICtrlCreateButton("&New query", 600, 70, 80, 20)
;$bt_rcopy = GUICtrlCreateButton("&Clipboard" , 600, 140, 80, 20)
;$bt_rsaveas = GUICtrlCreateButton("Save &as" , 600, 180, 80, 20)
GUICtrlCreateTabItem("") ; end of Tab control

; Monitor tab
$tab_monitor = GUICtrlCreateTabItem(" Monitor AT ")
GUICtrlSetState($tab_monitor, $GUI_DISABLE)
$inp_rows = GUICtrlCreateInput(25, 600, 80, 80, 20)
$lab_rows = GUICtrlCreateLabel("Rows: ", 600, 60, 80, 20)
$lst_monitor = GUICtrlCreateListView($s_MonitorHdr, 20, 50, 550, 150)
$lst_monitor1 = GUICtrlCreateListView($s_MonitorHdr, 20, 270, 550, 150)
$bt_monitorstart = GUICtrlCreateButton("&Start", 600, 210, 80, 20)
$b_size = ControlGetPos("", "", $lst_monitor)
$lab_sql2 = GUICtrlCreateLabel($sql_str_1, 20, $b_size[1] - 15, 550, 150)
$c_size = ControlGetPos("", "", $lst_monitor1)
$lab_sql2 = GUICtrlCreateLabel($sql_str_2, 20, $c_size[1] - 15, 550, 150)


GUICtrlCreateTabItem("") ; end of Tab control

; --- Show Gui ---
GUICtrlSetState($lst_dsn, $GUI_FOCUS) ; Focus on dsn list
GUISetState(@SW_SHOW, $h_Gui)

onload()
While 1
    $msg = GUIGetMsg()
    If $msg <> 0 Then
        Select
            Case $msg = $GUI_EVENT_CLOSE Or $msg = $mn_exit
                ExitLoop
            Case $msg = $mn_open Or $msg = $bt_open
                SQLopen()
            Case $msg = $mn_saveas Or $msg = $bt_saveas
                SQLsave()
            Case $msg = $bt_monitorstart
                GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events")

                If ValidateFields(GUICtrlRead($inp_rows)) Then

                    ; $sql_str_1_1 = "SELECT FIRST "& GUICtrlRead($inp_rows) & " * From tctaudit Order By AuditId DESC;"
                    ; $b_size = ControlGetPos("", "", $lst_monitor)
                    ; $lab_sql2 = GUICtrlCreateLabel($sql_str_1_1, 20, $b_size[1]- 15, 550, 150)



                    ;while 1
                    ODBCMonitorQuery("SELECT FIRST " & GUICtrlRead($inp_rows) & " * From tctaudit Order By AuditId DESC; ")
                    ;sleep(1000)
                    ;WEnd
                EndIf



            Case $msg = $mn_status
                If BitAND(GUICtrlRead($mn_status), $GUI_CHECKED) = $GUI_CHECKED Then
                    GUICtrlSetState($mn_status, $GUI_UNCHECKED)
                    GUICtrlSetState($sb_connect, $GUI_HIDE)
                    GUICtrlSetState($sb_info, $GUI_HIDE)
                Else
                    GUICtrlSetState($mn_status, $GUI_CHECKED)
                    GUICtrlSetState($sb_connect, $GUI_SHOW)
                    GUICtrlSetState($sb_info, $GUI_SHOW)
                EndIf
            Case $msg = $mn_odbc
                If BitAND(GUICtrlRead($mn_odbc), $GUI_CHECKED) = $GUI_CHECKED Then
                    GUICtrlSetState($mn_odbc, $GUI_UNCHECKED)
                    $i_ObjectDebug = 0
                Else
                    GUICtrlSetState($mn_odbc, $GUI_CHECKED)
                    $i_ObjectDebug = 1
                EndIf
                ;Case $msg = $mn_about
                ; About()
            Case $msg = $bt_conn
                ODBCconnect()
            Case $msg = $bt_discon
                $o_ADOconn.Close
                GUICtrlSetState($bt_conn, $GUI_ENABLE)
                GUICtrlSetState($bt_discon, $GUI_DISABLE)
                GUICtrlSetState($mn_open, $GUI_DISABLE)
                GUICtrlSetState($mn_recent, $GUI_DISABLE)
                GUICtrlSetState($mn_saveas, $GUI_DISABLE)
                GUICtrlSetState($tab_schema, $GUI_DISABLE)
                GUICtrlSetState($tab_query, $GUI_DISABLE)
                GUICtrlSetState($tab_result, $GUI_DISABLE)

                GUICtrlSetState($bt_tbl, $GUI_DISABLE)
                GUICtrlSetState($bt_col, $GUI_DISABLE)
                GUICtrlSetState($bt_scopy, $GUI_DISABLE)
                GUICtrlSetState($bt_ssaveas, $GUI_DISABLE)
                $b_ADOiscon = 0
                StatusBar("Disconnected")
                ;Case $msg = $bt_db
                ; ODBCschema($i_ADOadSchemaCatalogs)
            Case $msg = $bt_tbl
                ODBCschema($i_ADOadSchemaTables)
            Case $msg = $bt_col
                ODBCschema($i_ADOadSchemaColumns)
            Case $msg = $bt_scopy
                SAVElist($lst_schema, $s_SchemaHdr) ; clipboard copy
            Case $msg = $bt_ssaveas
                SAVElist($lst_result, $s_ResultHdr, "file") ; save schema to file
            Case $msg = $bt_run
                ODBCquery(GUICtrlRead($ed_qry))
            Case $msg = $bt_clr
                GUICtrlSetData($ed_qry, "") ; clear data
                GUICtrlSetState($lst_result, $GUI_FOCUS)
            Case $msg = $bt_new
                GUICtrlSetState($tab_query, $GUI_SHOW) ; show query tab
                GUICtrlSetState($ed_qry, $GUI_FOCUS) ; select edit field
                ;Case $msg = $bt_rcopy
                ; SAVElist($lst_result,$s_ResultHdr) ; clipboard copy
                ;Case $msg = $bt_rsaveas
                ; SAVEList($lst_result,$s_ResultHdr, "file") ; save result to file
            Case $msg = $tab_query
                GUICtrlSetState($tab_query, $GUI_SHOW) ; show query tab
                GUICtrlSetState($ed_qry, $GUI_FOCUS) ; select edit field
        EndSelect
    EndIf
WEnd
GUIDelete()
Exit

Func SAVElist($l_list, $s_hdr = "", $filenm = "")
    Local $a_indices = _GUICtrlListViewGetSelectedIndices($l_list, 1)
    If (IsArray($a_indices)) Then
        Local $i, $buf
        $buf = $s_hdr & @LF
        For $i = 1 To $a_indices[0]
            $buf &= _GUICtrlListViewGetItemText($l_list, $a_indices[$i], -1) & @LF
        Next
        If $filenm <> "" Then
            $filenm = FileSaveDialog("Save as...", '.', "All files (*.*)", 3)
            If @error <> 1 Then
                FileWrite($filenm, $buf)
                GUICtrlSetData($sb_info, "Selected rows saved to file")
            EndIf
        Else
            ClipPut($buf)
            GUICtrlSetData($sb_info, "Selected rows copied to clipboard")
        EndIf
    Else
        GUICtrlSetData($sb_info, "Not Items Selected")
    EndIf
EndFunc   ;==>SAVElist

Func SQLopen()
    If $b_ADOiscon = 1 Then
        $s_filenm = FileOpenDialog("Choose file...", '.', "SQLfiles (*.sql)|All (*.*)")
        If @error <> 1 Then
            GUICtrlCreateMenuitem($s_filenm, $mn_recent)
            GUICtrlSetData($ed_qry, FileRead($s_filenm, 4096))
        EndIf
    EndIf
EndFunc   ;==>SQLopen

Func SQLsave()
    If $b_ADOiscon = 1 Then
        $s_filenm = FileSaveDialog("Save as...", $s_filenm, "SQLfiles (*.sql)", 3)
        If @error <> 1 Then
            FileWrite($s_filenm, GUICtrlRead($ed_qry))
        EndIf
    EndIf
EndFunc   ;==>SQLsave


Func ODBCsources($h_controlID, $s_RegEntry, $s_Type)
    Local $s_List, $i_DSNcount, $s_VarNm, $s_Value, $i
    $i = 1
    $s_VarNm = RegEnumVal($s_RegEntry, $i)
    $s_Value = RegRead($s_RegEntry, $s_VarNm)
    While $s_VarNm <> ""
        $s_VarNm = RegEnumVal($s_RegEntry, $i)
        $s_Value = RegRead($s_RegEntry, $s_VarNm)
        If $s_VarNm <> "" Then
            GUICtrlCreateListViewItem($s_VarNm & "|" & $s_Type & "|" & $s_Value, $h_controlID)
            $i += 1
            $i_DSNcount += 1
        EndIf
    WEnd
EndFunc   ;==>ODBCsources

Func ODBCconnect()
    $dsnarray = StringSplit((GUICtrlRead(GUICtrlRead($lst_dsn), 2)), "|") ; retrieve selected row
    If $dsnarray[1] <> "" Then
        $s_DSNname = $dsnarray[1]
        $s_DSNuid = GUICtrlRead($inp_uid)
        $s_DSNpwd = GUICtrlRead($inp_pwd)
        $s_DSNdb = GUICtrlRead($inp_db)
        $s_DSNfull = "DSN=" & $s_DSNname & ";"
        If $s_DSNuid <> "" Then $s_DSNfull &= "Uid=" & $s_DSNuid & ";"
        If $s_DSNpwd <> "" Then $s_DSNfull &= "Pwd=" & $s_DSNpwd & ";"
        If $s_DSNdb <> "" Then $s_DSNfull &= "database=" & $s_DSNdb & ";"
        $o_ADOconn = ObjCreate("ADODB.Connection")
        $o_ADOconn.Open ($s_DSNfull)
        If @error Then
            MsgBox(64, "Connection error", "Error connecting to database DSN=[" & $s_DSNfull & "]")
        Else
            GUICtrlSetState($bt_conn, $GUI_DISABLE)
            GUICtrlSetState($bt_discon, $GUI_ENABLE)
            StatusBar("", "Connected to " & $s_DSNname)
            GUICtrlSetState($tab_schema, $GUI_ENABLE)
            GUICtrlSetState($tab_query, $GUI_ENABLE)
            GUICtrlSetState($tab_result, $GUI_ENABLE)
            GUICtrlSetState($tab_query, $GUI_SHOW) ; show query tab
            GUICtrlSetState($ed_qry, $GUI_FOCUS) ; select edit field
            GUICtrlSetState($mn_open, $GUI_ENABLE)
            GUICtrlSetState($mn_recent, $GUI_ENABLE)
            GUICtrlSetState($mn_saveas, $GUI_ENABLE)

            GUICtrlSetState($bt_tbl, $GUI_ENABLE)
            GUICtrlSetState($bt_col, $GUI_ENABLE)
            GUICtrlSetState($bt_scopy, $GUI_ENABLE)
            GUICtrlSetState($bt_ssaveas, $GUI_ENABLE)

            $b_ADOiscon = 1
        EndIf
    EndIf
EndFunc   ;==>ODBCconnect

Func StatusBar($info, $conn = "")
    If $conn <> "" Then GUICtrlSetData($sb_connect, $conn)
    If $info <> "" Then GUICtrlSetData($sb_info, $info)
EndFunc   ;==>StatusBar


Func ODBCquery($s_Qry)
    Local $cmboVal, $n
    StatusBar("Starting query...")

    $o_ADOrs = ObjCreate("ADODB.Recordset")
    $o_ADOrs.CursorType = $i_adOpenDynamic
    $o_ADOrs.LockType = $i_adLockOptimistic
    $o_ADOrs.Open ($s_Qry, $o_ADOconn)
    If @error Then
        MsgBox(64, "Info", "Error in query !", 2);
        StatusBar("Error in query !");
        Return
    EndIf

    GUICtrlSetState($tab_result, $GUI_SHOW) ; show result tab
    GUISwitch($h_Gui, $tab_result)
    $a_size = ControlGetPos("", "", $lst_schema) ; retrieve controls current postion and size
    GUICtrlDelete($lst_result)
    With $o_ADOrs
        $s_ResultHdr = "" ; Get information about Fields collection
        For $n = 0 To .Fields.Count - 1
            $s_ResultHdr &= .Fields ($n).Name & "|"
        Next
        $lst_result = GUICtrlCreateListView($s_ResultHdr, $a_size[0], $a_size[1], $a_size[2], $a_size[3], $LVS_REPORT, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES))
        GUICtrlSetResizing(-1, $GUI_DOCKAUTO)

        If .RecordCount Then
            While Not .EOF
                $cmboVal = ""
                For $n = 0 To .Fields.Count - 1
                    $cmboVal = $cmboVal & .Fields ($n).Value & "|"
                Next
                $cmboVal = StringTrimRight($cmboVal, 1)
                GUICtrlCreateListViewItem($cmboVal, $lst_result)
                .MoveNext
            WEnd
        EndIf
    EndWith
    GUICtrlCreateTabItem("")
    GUICtrlSetState($lst_result, $GUI_FOCUS)
    StatusBar("Done")
    GUISetState(@SW_SHOW, $h_Gui)
EndFunc   ;==>ODBCquery


Func ODBCschema($i_qrytype)
    Local $n
    GUICtrlSetState($tab_schema, $GUI_SHOW) ; show result tab
    GUISwitch($h_Gui, $tab_schema)

    $a_size = ControlGetPos("", "", $lst_schema) ; retrieve controls current postion and size
    GUICtrlDelete($lst_schema)

    StatusBar("Retrieving schema..")
    $o_ADOrs = $o_ADOconn.OpenSchema ($i_qrytype)

    With $o_ADOrs
        $s_SchemaHdr = "" ; Get information about Fields collection
        For $n = 0 To .Fields.Count - 1
            $s_SchemaHdr &= .Fields ($n).Name & "|"
        Next
        $lst_schema = GUICtrlCreateListView($s_SchemaHdr, $a_size[0], $a_size[1], $a_size[2], $a_size[3], $LVS_REPORT, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES))
        GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
        While Not .EOF
            $cmboVal = ""
            For $n = 0 To .Fields.Count - 1
                $cmboVal &= .Fields ($n).Value & "|"
            Next
            $cmboVal = StringTrimRight($cmboVal, 1)
            GUICtrlCreateListViewItem($cmboVal, $lst_schema)
            .MoveNext
        WEnd
    EndWith
    GUICtrlCreateTabItem("")
    GUICtrlSetState($lst_schema, $GUI_FOCUS)
    StatusBar("Done")
    GUISetState(@SW_SHOW, $h_Gui)
EndFunc   ;==>ODBCschema


; ========================================
; GUI - About
; ========================================
Func About()
    ; $gui_About = GuiCreate('About', 315, 200, -1, -1, BitOr($WS_CAPTION, $WS_SYSMENU), -1, $h_Gui)
    ; GUICtrlCreateIcon ("shell32.dll", 175, 5,8)
    ; GuiCtrlCreateLabel($s_Title & ' v' & $s_Version & ' - The Simple Query Utility' & @LF &_
    ; @LF &_
    ; 'This application is a simple program for easily retrieving ' &_
    ; 'information from a database using ODBC. ' & @LF &_
    ; @LF &_
    ; 'It was written in AutoIt3 script by Hans Harder.' & @LF &_
    ; @LF &_
    ; ' ' , 45, 15, 290, 140)
    ; $lb_Ab_VisitSite = _GuiCtrlCreateHyperlink('Visit the AutoIt Website', 5, 155, 165, 15, 0x0000ff, 'http://www.autoitscript.com')
    ; $lb_Ab_ContactAuthor = _GuiCtrlCreateHyperlink('Contact Hans Harder', 5, 175, 165, 15, 0x0000ff, 'mailto:hans@atabas.org')
    ; $bt_Ab_Close = GuiCtrlCreateButton('&Close', 225, 165, 75, 25)
    ; GuiSetState(@SW_SHOW, $gui_About)

    ; While 1
    ; $msg = GUIGetMsg()
    ; if $msg <> 0 then
    ; Select
    ; Case $msg = $lb_Ab_VisitSite
    ; _Start('http://www.autoitscript.com')
    ; Case $msg = $lb_Ab_ContactAuthor
    ; _Start('"mailto:hans@atbas.org?Subject=AutoIt3 QDBCquery Application"')
    ; Case $msg = $GUI_EVENT_CLOSE Or $msg = $bt_Ab_Close
    ; ExitLoop
    ; EndSelect
    ; Endif
    ; WEnd
    ; GuiSetState(@SW_HIDE, $gui_About)
    ; GuiDelete($gui_About)
EndFunc   ;==>About

;===============================================================================
;
; Function Name: _GuiCtrlCreateHyperlink()
; Description: Creates a label that acts as a hyperlink
;
; Parameter(s): $s_Text - Label text
; $i_Left - Label left coord
; [$i_Top] - Label top coord
; [$i_Width] - Label width
; [$i_Height] - Label height
; [$i_Color] - Text Color
; [$s_ToolTip] - Hyperlink ToolTip
; [$i_Style] - Label style
; [$i_ExStyle] - Label extended style
;
; Requirement(s): None
; Return Value(s): Control ID
;
; Author(s): Saunders <krawlie@hotmail.com>
;
;===============================================================================
; $lb_Ab_VisitSite = _GuiCtrlCreateHyperlink('Visit the AutoIt Website', 5, 155, 165, 15, 0x0000ff, 'http://www.autoitscript.com')
Func _GuiCtrlCreateHyperlink($S_TEXT, $I_LEFT, $I_TOP, _
        $I_WIDTH = -1, $I_HEIGHT = -1, $I_COLOR = 0x0000ff, $S_TOOLTIP = '', $I_STYLE = -1, $I_EXSTYLE = -1)
    Local $I_CTRLID
    $I_CTRLID = GUICtrlCreateLabel($S_TEXT, $I_LEFT, $I_TOP, $I_WIDTH, $I_HEIGHT, $I_STYLE, $I_EXSTYLE)
    If $I_CTRLID <> 0 Then
        GUICtrlSetFont($I_CTRLID, -1, -1, 4)
        GUICtrlSetColor($I_CTRLID, $I_COLOR)
        GUICtrlSetCursor($I_CTRLID, 0)
    EndIf
    Return $I_CTRLID
EndFunc   ;==>_GuiCtrlCreateHyperlink

Func _Start($s_StartPath)
    If @OSTYPE = 'WIN32_NT' Then
        $s_StartStr = @ComSpec & ' /c start "" '
    Else
        $s_StartStr = @ComSpec & ' /c start '
    EndIf
    Run($s_StartStr & $s_StartPath, '', @SW_HIDE)
EndFunc   ;==>_Start

Func Object_Error()
    $HexNumber = Hex($o_ComError.number, 8)
    $s_ObjectError = "COM Error = " & $HexNumber & @CRLF & _
            "Windescription is: " & $o_ComError.windescription
    If $i_ObjectDebug <> 0 Then MsgBox(64, "Database error", "Database Error : " & $s_ObjectError & "")
    SetError(1) ; something to check for when this function returns
EndFunc   ;==>Object_Error

Func onload()
    GUICtrlSetState($bt_tbl, $GUI_DISABLE)
    GUICtrlSetState($bt_col, $GUI_DISABLE)
    GUICtrlSetState($bt_scopy, $GUI_DISABLE)
    GUICtrlSetState($bt_ssaveas, $GUI_DISABLE)

EndFunc   ;==>onload

Func ODBCMonitorQuery($s_Qry)
    Local $cmboVal, $n
    GUICtrlSetState($lst_monitor, $GUI_DISABLE)
    StatusBar("Starting query...")
    GUISetState(81, $lst_monitor1)
    $o_ADOrs = ObjCreate("ADODB.Recordset")
    $o_ADOrs.CursorType = $i_adOpenDynamic
    $o_ADOrs.LockType = $i_adLockOptimistic
    $o_ADOrs.Open ($s_Qry, $o_ADOconn)
    If @error Then
        MsgBox(64, "Info", "Error occured !", 2);
        StatusBar("Error occured!");
        Return
    EndIf

    GUICtrlSetState($tab_monitor, $GUI_SHOW)
    GUISwitch($h_Gui, $tab_monitor)
    $a_size = ControlGetPos("", "", $lst_schema)
    GUICtrlDelete($lst_monitor)
    With $o_ADOrs
        $s_MonitorHdr = ""
        For $n = 0 To .Fields.Count - 1
            $s_MonitorHdr &= .Fields ($n).Name & "|"
        Next
        $lst_monitor = GUICtrlCreateListView($s_MonitorHdr, $a_size[0], $a_size[1], $a_size[2], $a_size[3] / 2, $LVS_REPORT, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES))

        GUICtrlSetResizing(-1, $GUI_DOCKAUTO)

        If .RecordCount Then
            While Not .EOF
                $cmboVal = ""
                For $n = 0 To .Fields.Count - 1
                    $cmboVal = $cmboVal & .Fields ($n).Value & "|"
                Next
                $cmboVal = StringTrimRight($cmboVal, 1)
                GUICtrlCreateListViewItem($cmboVal, $lst_monitor)
                .MoveNext
            WEnd
        EndIf
    EndWith
    GUICtrlCreateTabItem("")
    GUICtrlSetState($lst_monitor, $GUI_FOCUS)
    StatusBar("Done")
    GUICtrlSetState($lst_monitor, $GUI_ENABLE)
    GUISetState(@SW_SHOW, $h_Gui)

EndFunc   ;==>ODBCMonitorQuery


Func ODBCMonitorQuery1($s_Qry)
    Local $cmboVal, $n
    StatusBar("Starting query...")

    $o_ADOrs = ObjCreate("ADODB.Recordset")
    $o_ADOrs.CursorType = $i_adOpenDynamic
    $o_ADOrs.LockType = $i_adLockOptimistic
    $o_ADOrs.Open ($s_Qry, $o_ADOconn)
    If @error Then
        MsgBox(64, "Info", "Error occured !", 2);
        StatusBar("Error occured!");
        Return
    EndIf

    GUICtrlSetState($tab_monitor, $GUI_SHOW)
    GUISwitch($h_Gui, $tab_monitor)
    $a_size = ControlGetPos("", "", $lst_schema)
    GUICtrlDelete($lst_monitor1)
    With $o_ADOrs
        $s_MonitorHdr = ""
        For $n = 0 To .Fields.Count - 1
            $s_MonitorHdr &= .Fields ($n).Name & "|"
        Next
        ;msgBox(0,0, $a_size[0] & " " & $a_size[1] & " " & $a_size[2] & " " & $a_size[3])
        ;$b_size = ControlGetPos("", "", $lst_monitor)
        ;MsgBox(0,$b_size[1],$b_size[1])
        $lst_monitor1 = GUICtrlCreateListView($s_MonitorHdr, $a_size[0], ($a_size[1] + $a_size[3] / 3) + $a_size[3] / 3, $a_size[2], $a_size[3] / 3, $LVS_REPORT, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES))
        GUICtrlSetResizing(-1, $GUI_DOCKAUTO)

        If .RecordCount Then
            While Not .EOF
                $cmboVal = ""
                For $n = 0 To .Fields.Count - 1
                    $cmboVal = $cmboVal & .Fields ($n).Value & "|"
                Next
                $cmboVal = StringTrimRight($cmboVal, 1)
                GUICtrlCreateListViewItem($cmboVal, $lst_monitor1)
                .MoveNext
            WEnd
        EndIf
    EndWith
    GUICtrlCreateTabItem("")
    GUICtrlSetState($lst_monitor1, $GUI_FOCUS)
    StatusBar("Done")
    GUISetState(@SW_SHOW, $h_Gui)

EndFunc   ;==>ODBCMonitorQuery1

Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam)
    #forceref $hWndGUI, $MsgID, $wParam
    Local $tagNMHDR, $event, $hwndFrom, $code
    $tagNMHDR = DllStructCreate("int;int;int", $lParam)
    If @error Then Return
    $event = DllStructGetData($tagNMHDR, 3)
    Select
        Case $wParam = $lst_monitor
            Select
                Case $event = $NM_CLICK
                    ListView_Click("lst_monitor")
                Case $event = $NM_DBLCLK
                    ListView_DoubleClick("lst_monitor")
            EndSelect
            ;Case $wParam = $lst_monitor1
            ; Select
            ; Case $event = $NM_CLICK
            ; ListView_Click ("lst_monitor1")
            ; Case $event = $NM_DBLCLK
            ; ListView_DoubleClick ("lst_monitor1")
            ; EndSelect
    EndSelect

    $tagNMHDR = 0
    $event = 0
    $lParam = 0
EndFunc   ;==>WM_Notify_Events

Func ListView_Click($monitor)
    Local $arr
    Select
        Case $monitor = "lst_monitor"

            $arr = StringSplit(_GUICtrlListViewGetItemText($lst_monitor, _GUICtrlListViewGetSelectedIndices($lst_monitor)), "|")
            ODBCMonitorQuery1("select * from tctauditproperties where auditpropid =" & $arr[2])

            ;$sql_str_2_2 = "select * from tctauditproperties where auditpropid =" & $arr[2]

            ;$c_size = ControlGetPos("", "", $lst_monitor1)
            ;$lab_sql2 = GUICtrlCreateLabel($sql_str_2_2, 20, $c_size[1]- 15, 550, 150)
        Case $monitor = "lst_monitor1"
            ; MsgBox(0,"Data Row", _GUICtrlListViewGetItemText ($lst_monitor1, _GUICtrlListViewGetSelectedIndices($lst_monitor1)))
    EndSelect
EndFunc   ;==>ListView_Click

Func ListView_DoubleClick($monitor)
    Select
        Case $monitor = "lst_monitor"
            MsgBox(64, "Data Row", _GUICtrlListViewGetItemText($lst_monitor, _GUICtrlListViewGetSelectedIndices($lst_monitor)), 10)
        Case $monitor = "lst_monitor1"
            ; MsgBox(0,"Data Row", _GUICtrlListViewGetItemText ($lst_monitor1, _GUICtrlListViewGetSelectedIndices($lst_monitor1)))
    EndSelect
EndFunc   ;==>ListView_DoubleClick

Func ValidateFields($Eve)

    $Eve = Int($Eve)
    If $Eve = 0 Then
        MsgBox(0, "Error", "Number of rows must be numeric.")
        Return 0
    EndIf
    If $Eve < 0 Then
        MsgBox(0, "Error", "The number of rows must be a positive number greater then 1")
        Return 0
    EndIf

    If GUICtrlRead($inp_rows) = "" Then


        MsgBox(0, "Error", "You must select at least one row")
        Return 0
    EndIf
    Return 1
EndFunc   ;==>ValidateFields

Alot of code without a error description. I hope your not in a rush for someone to help.

:)

Share this post


Link to post
Share on other sites

Well, I am realy rush to get help


Be Green Now or Never (BGNN)!

Share this post


Link to post
Share on other sites

Can't you just use the stable if it's that important?

Share this post


Link to post
Share on other sites

Can't you just use the stable if it's that important?

I already installed the beta and i do not remember the version of the stable one (beside, i do not know where to get it anymore).

The main GUI does not show up withou any error.


Be Green Now or Never (BGNN)!

Share this post


Link to post
Share on other sites

Well, I am realy rush to get help

Well if you are in a rush it might help when you clearly describe what the problem is, unless you expect us to be clairvoyant :whistle:

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Well if you are in a rush it might help when you clearly describe what the problem is, unless you expect us to be clairvoyant :whistle:

Well I just wrote it up, The main GUI does not show up.

Also, there is no any error indication for the cause , just simply.

Just run the script with current beta and you'll get see the problem easily.


Be Green Now or Never (BGNN)!

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Well I just wrote it up, The main GUI does not show up.

Also, there is no any error indication for the cause , just simply.

Just run the script with current beta and you'll get see the problem easily.

Seems like All questions need to be asked before any more info is given .... :whistle:

- does it stop running, if so any errors shown in the outputpane of SciTE?

- does it hang ?

- if so where is it hanging on ?

To help figure that out just make these changes at the top of your script to show where the script is Hanging:

;#NoTrayIcon

Opt("TrayIconDebug", 1)

#include <GUIConstants.au3>

#include <GUIListView.au3>

When I comment these lines the GUI shows :

;ODBCsources($lst_dsn, $s_ODBCregUser, "USER")

;ODBCsources($lst_dsn, $s_ODBCregSystem, "SYSTEM")

;_GUICtrlListViewSetItemSelState($lst_dsn, 0) ; select the first row

Maybe that gives you a place to start looking ?

Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

I do not see a Gui with any version.

It could be the calls to this function before you GuiSetState() your gui causing the issue. Looks like a lack of error checking (after RegEnumVal) and perhaps getting stuck in the loop?

Func ODBCsources($h_controlID, $s_RegEntry, $s_Type)
    Local $s_List, $i_DSNcount, $s_VarNm, $s_Value, $i
    $i = 1
    $s_VarNm = RegEnumVal($s_RegEntry, $i)
    $s_Value = RegRead($s_RegEntry, $s_VarNm)
    While $s_VarNm <> ""
        $s_VarNm = RegEnumVal($s_RegEntry, $i)
        $s_Value = RegRead($s_RegEntry, $s_VarNm)
        If $s_VarNm <> "" Then
            GUICtrlCreateListViewItem($s_VarNm & "|" & $s_Type & "|" & $s_Value, $h_controlID)
            $i += 1
            $i_DSNcount += 1
        EndIf
    WEnd
EndFunc   ;==>ODBCsources

Share this post


Link to post
Share on other sites

I do not see a Gui with any version.

I get an error with Beta and not with Prod when I just comment these 2 lines but am not sure if thats the OP's issue:

;ODBCsources($lst_dsn, $s_ODBCregUser, "USER")

;ODBCsources($lst_dsn, $s_ODBCregSystem, "SYSTEM")

_GUICtrlListViewSetItemSelState($lst_dsn, 0) ; select the first row

(143) : ==> Subscript used with non-Array variable.: 
$lab_sql2 = GUICtrlCreateLabel($sql_str_1, 20, $b_size[1] - 15, 550, 150) 
$lab_sql2 = GUICtrlCreateLabel($sql_str_1, 20, $b_size^ ERROR

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Well, I think that you are both (MHz and JDeb) were right about where the problems occurs.

I have done it step by step but still do not know why it is a problem.

The script was working before the upgrade. Maybe soemthing is wrong with the "GUICtrlCreateListViewItem" function that inside the ODBCsources function procedure?

Edited by lsakizada

Be Green Now or Never (BGNN)!

Share this post


Link to post
Share on other sites

Well, I think that you are both (MHz and JDeb) were right about where the problems occurs.

I have done it step by step but still do not know why it is a problem.

The script was working before the upgrade. Maybe soemthing is wrong with the "GUICtrlCreateListViewItem" function?

Don't see any answers on my questions ?

I am not in the business of guessing :whistle:


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Sory, missed you: :">

- does it stop running, if so any errors shown in the outputpane of SciTE?

Not stopping, No errors.

- does it hang ?

No hangs.

The command Opt("TrayIconDebug", 1) does not give anything

Edited by lsakizada

Be Green Now or Never (BGNN)!

Share this post


Link to post
Share on other sites

How can it exit the loop in the function if $s_VarNm is always unequal to ""?

Share this post


Link to post
Share on other sites

How can it exit the loop in the function if $s_VarNm is always unequal to ""?

Well I just checked it. I added consolewrite to get the return from this function. it is returned 0 and not "". That's mean that this stable function was modified.

What to do to fixed it?

code:

Func ODBCsources($h_controlID, $s_RegEntry, $s_Type)
    Local $s_List, $i_dsncount, $s_VarNm, $s_Value, $i
    $i = 1
    $s_VarNm = RegEnumVal($s_RegEntry,  $i)
    $s_Value = RegRead($s_RegEntry, $s_Varnm)
    While $s_VarNm <> ""
        $s_VarNm = RegEnumVal($s_RegEntry,  $i)
        $s_Value = RegRead($s_RegEntry, $s_Varnm)
        If $s_Varnm <> "" Then
            $ddd =GUICtrlCreateListViewItem($s_VarNm & "|" & $s_Type & "|" & $s_Value, $h_controlID)
            consolewrite($ddd & @CRLF)
            $i += 1
            $i_DSNcount += 1
        EndIf
    Wend
EndFunc

Be Green Now or Never (BGNN)!

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

Sory, missed you: :">

Not stopping, No errors.

No hangs.

The command Opt("TrayIconDebug", 1) does not give anything

Sorry but I am totally lost now since these 2 are mutually exclusive ... in other words... the script Hangs or stops due to exits/crash ....

When you make the changes as I proposed, the Systray icon is shown and you can hover over this icon to see at which statement the script is running.

When the trayIcon disapears, it means the execution is stopped.....

Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Sorry but I am totally lost now since these 2 are mutually exclusive ... in other words... the script Hangs or stops due to exits/crash ....

When you make the changes as I proposed, the Systray icon is shown and you can hover over this icon to see at which statement the script is running.

When the trayIcon disapears, it means the execution is stopped.....

JDeb, See above, the cause is about infinite looping in the ODBCsources() function. It's actually hang, I was missleading you.

The $s_VarNm parameter never give empty string "". This used to work before. I still don't know how to fix it.


Be Green Now or Never (BGNN)!

Share this post


Link to post
Share on other sites

Try this line right after the RegEnumVal()

If @error Then ExitLoop

well, it gives this error:

If C:\QA\Autoit-Tools\DB\AuditTrail.au3 (145) : ==> Subscript used with non-Array variable.:

$lab_sql2 = GUICtrlCreateLabel($sql_str_1, 20, $b_size[1]- 15, 550, 150)

$lab_sql2 = GUICtrlCreateLabel($sql_str_1, 20, $b_size^ ERROR

->AutoIT3.exe ended.rc:1

>Exit code: 1 Time: 1.425


Be Green Now or Never (BGNN)!

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

If you look closely at that function 'ODBCsources' you'll see that you have (and use)

$s_varNm

and

$s_varnm

now I haven't been around long enough to know how strict case is in AutoIt - or has been - but for starters I'd put

Opt ("MustDeclareVars", 1)

plenty of undeclared vars to keep you amused for a while :">

Edited by Gollum

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  
Followers 0