1. Dashboard
  2. Mitglieder
    1. Letzte Aktivitäten
    2. Benutzer online
    3. Team
    4. Mitgliedersuche
  3. Forenregeln
  4. Forum
    1. Unerledigte Themen
  • Anmelden
  • Registrieren
  • Suche
Alles
  • Alles
  • Artikel
  • Seiten
  • Forum
  • Erweiterte Suche
  1. AutoIt.de - Das deutschsprachige Forum.
  2. Mitglieder
  3. Neight

Beiträge von Neight

  • dListview

    • Neight
    • 3. Juli 2019 um 15:56

    Hallo Musashi,

    ich hatte mir die sqlite3.dll schon woanders runtergeladen. Jetzt habe ich sie von dem von dir angegeben Link nochmal geladen.

    Das Problem scheint jetzt behoben zu sein.

    Mein vorrangegangenes Problem konnte ich auch beheben. Ich habe _SQLite_GetTable2d anstelle von _SQLite_Query genommen.

    Vielen Dank für eure Hilfe.:)

  • dListview

    • Neight
    • 3. Juli 2019 um 10:10

    Hallo autoiter,

    oh na klar, sry.., hatte ich ganz vergessen gestern noch mit dran zu hängen.

    Code
    Func _add($id)
        _readipt()
        Local $retarr
        _SQLite_QuerySingleRow($dbn, "SELECT id FROM MineralDB WHERE id='" & $id & "'", $retarr)
        If $retarr[0] <> "" Then
            _SQLite_Exec($dbn, "UPDATE MineralDB SET Name='" _
                     & $aStr[0] & "', Synonyme='" & $aStr[1] & "',Paragenese='" & $aStr[2] & "',Formel='" & $aStr[3] & "',Dichte='" & $aStr[4] _
                     & "',Härte='" & $aStr[5] & "',Fundort='" & $aStr[6] & "',Fundland='" & $aStr[7] & "',Bild='" & $Picture & "',Radioaktiv='" & $aStr[9] & "',Magnetisch='" & $aStr[10] & "',Fluoreszierend='" & $aStr[11] & "' WHERE id='" & $id & "'")
        Else
            _SQLite_Exec($dbn, "INSERT INTO MineralDB (ID,Name,Synonyme,Paragenese,Formel,Dichte,Härte,Fundort,Fundland,Bild,Radioaktiv,Magnetisch,Fluoreszierend) VALUES ('" _
                     & $num & "','" & $aStr[0] & "','" & $aStr[1] & "','" & $aStr[2] _
                     & "','" & $aStr[3] & "','" & $aStr[4] & "','" & $aStr[5] & "','" _
                     & $aStr[6] & "','" & $aStr[7] & "', '" & $Picture & "','" & $aStr[9] & "','" & $aStr[10] & "','" & $aStr[11] & "');")
        EndIf
        _SQLite_CountRows('MineralDB')
    EndFunc 
    Alles anzeigen
  • dListview

    • Neight
    • 2. Juli 2019 um 21:03

    Hallo Bert,

    ich habe dir mal die komplette Funtion unten reingestellt, wegen der Listview.

    Also könnte ich das theoretisch wie hier lösen? Das ich das nach dem Sortieren der DB, es über _SQLite_GetTable2d auslese?

    Code
    _SQLite_GetTable2d(-1,'SELECT * FROM MineralDB ;', $aResult, $iRows, $iColumns)
    _GUICtrlListView_BeginUpdate($ListView)
        For $i = 1 To UBound($aResult) -1 Step 1        _GUICtrlListView_AddItem($ListView, $aResult[$i][0])        _GUICtrlListView_AddSubItem($ListView, $i-1, $aResult[$i][1], 1)        _GUICtrlListView_AddSubItem($ListView,$i-1,$aResult[$i][7], 2, 2)
        Next


    Code
    Func _Inhaltsverzeichnis()
    Global  $sHeader = "XXX|XXXXX|XXXXXXX"
    Global $aHeaderSplit = StringSplit($sHeader, '|')
    Local $aResult, $iRows, $iColumns
    
    $hGui = GUICreate("Inhaltsverzeichnis", 580, 402, 192, 125)
    ;GUISetBkColor($g_iGuiBkColor)
    Global $ListView = GUICtrlCreateListView($sHeader, 0, 0, 600, 320)
    _GUICtrlListView_SetExtendedListViewStyle($ListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_INFOTIP))
    _GUICtrlListView_JustifyColumn($ListView, 0, 1)
    _GUICtrlListView_SetTextColor($ListView, $g_iLVTextColor)
    _GUICtrlListView_SetTextBkColor($ListView, $g_iLVBkColor)
    _GUICtrlListView_SetOutlineColor($ListView, $g_iLVOlColor)
    GUICtrlSetFont($ListView, 10, 800, 0, "Courier New")
    ;GUICtrlSetBkColor(-1, 0xFFFFFF) ; weiß
    ;GUICtrlSetBkColor(-1, $GUI_BKCOLOR_LV_ALTERNATE)
    Global $GetHandleLV = GUICtrlGetHandle($ListView)
    _GUICtrlListView_SetColumn($GetHandleLV, 0, $aHeaderSplit[1], 40, 1)
    _GUICtrlListView_SetColumn($GetHandleLV, 1, $aHeaderSplit[2], 200, 0)
    _GUICtrlListView_SetColumn($GetHandleLV, 2, $aHeaderSplit[3], 337, 0)
    $Button1 = GUICtrlCreateButton("Sortieren", 368, 344, 81, 41)
    $Button2 = GUICtrlCreateButton("Abbrechen", 464, 344, 81, 41)
    GUISetState(@SW_SHOW)
    
    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
    
    _SQLite_GetTable2d(-1,'SELECT * FROM MineralDB ;', $aResult, $iRows, $iColumns)
    _GUICtrlListView_BeginUpdate($ListView)
    
        For $i = 1 To UBound($aResult) -1 Step 1
            _GUICtrlListView_AddItem($ListView, $aResult[$i][0])
            _GUICtrlListView_AddSubItem($ListView, $i-1, $aResult[$i][1], 1)
            _GUICtrlListView_AddSubItem($ListView,$i-1,$aResult[$i][7], 2, 2)
    
        Next
    
        For $i = 1 To 15 Step 1
            _GUICtrlListView_AddItem($ListView, '')
        Next
    
        _GUICtrlListView_EndUpdate($ListView)
    ;_ArrayDisplay($aResult, "Results from the query")
    
    
    While True
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                GUIDelete($hGui)
                ExitLoop
            Case $Button2
                GUIDelete($hGui)
                ExitLoop
            Case $Button1
                _ListView()
    
        EndSwitch
    WEnd
    
    EndFunc
    
    Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
        #forceref $hWnd, $iMsg, $wParam
        Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $tInfo, $hWndListView = $ListView
        If Not IsHWnd($ListView) Then $hWndListView = GUICtrlGetHandle($ListView)
    
        $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
        $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
        $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
        $iCode = DllStructGetData($tNMHDR, "Code")
        Switch $hWndFrom
            Case $hWndListView
                Switch $iCode
                    Case $LVN_BEGINLABELEDITA, $LVN_BEGINLABELEDITW ; Start of label editing for an item
                        $tInfo = DllStructCreate($tagNMLVDISPINFO, $lParam)
                        _DebugPrint("$LVN_BEGINLABELEDIT" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                                "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                                "-->Code:" & @TAB & $iCode & @CRLF & _
                                "-->Mask:" & @TAB & DllStructGetData($tInfo, "Mask") & @CRLF & _
                                "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @CRLF & _
                                "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                                "-->State:" & @TAB & DllStructGetData($tInfo, "State") & @CRLF & _
                                "-->StateMask:" & @TAB & DllStructGetData($tInfo, "StateMask") & @CRLF & _
                                "-->Image:" & @TAB & DllStructGetData($tInfo, "Image") & @CRLF & _
                                "-->Param:" & @TAB & DllStructGetData($tInfo, "Param") & @CRLF & _
                                "-->Indent:" & @TAB & DllStructGetData($tInfo, "Indent") & @CRLF & _
                                "-->GroupID:" & @TAB & DllStructGetData($tInfo, "GroupID") & @CRLF & _
                                "-->Columns:" & @TAB & DllStructGetData($tInfo, "Columns") & @CRLF & _
                                "-->pColumns:" & @TAB & DllStructGetData($tInfo, "pColumns"))
                        Return False ; Allow the user to edit the label
                        ; ;Return True  ; Prevent the user from editing the label
                    Case $LVN_COLUMNCLICK ; A column was clicked
                        $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam)
                        _DebugPrint("$LVN_COLUMNCLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                                "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                                "-->Code:" & @TAB & $iCode & @CRLF & _
                                "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @CRLF & _
                                "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                                "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                                "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                                "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                                "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                                "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                                "-->Param:" & @TAB & DllStructGetData($tInfo, "Param"))
                        ; No return value
                    Case $LVN_ENDLABELEDITA, $LVN_ENDLABELEDITW ; The end of label editing for an item
                        $tInfo = DllStructCreate($tagNMLVDISPINFO, $lParam)
                        If (DllStructGetData($tInfo, "Text") <> 0) Then
                            Local $tBuffer = DllStructCreate("char Text[" & DllStructGetData($tInfo, "TextMax") & "]", DllStructGetData($tInfo, "Text"))
                            _DebugPrint("$LVN_ENDLABELEDIT" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                                    "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                                    "-->Code:" & @TAB & $iCode & @CRLF & _
                                    "-->Mask:" & @TAB & DllStructGetData($tInfo, "Mask") & @CRLF & _
                                    "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @CRLF & _
                                    "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                                    "-->State:" & @TAB & DllStructGetData($tInfo, "State") & @CRLF & _
                                    "-->StateMask:" & @TAB & DllStructGetData($tInfo, "StateMask") & @CRLF & _
                                    "-->Text:" & @TAB & DllStructGetData($tBuffer, "Text") & @CRLF & _
                                    "-->TextMax:" & @TAB & DllStructGetData($tInfo, "TextMax") & @CRLF & _
                                    "-->Image:" & @TAB & DllStructGetData($tInfo, "Image") & @CRLF & _
                                    "-->Param:" & @TAB & DllStructGetData($tInfo, "Param") & @CRLF & _
                                    "-->Indent:" & @TAB & DllStructGetData($tInfo, "Indent") & @CRLF & _
                                    "-->GroupID:" & @TAB & DllStructGetData($tInfo, "GroupID") & @CRLF & _
                                    "-->Columns:" & @TAB & DllStructGetData($tInfo, "Columns") & @CRLF & _
                                    "-->pColumns:" & @TAB & DllStructGetData($tInfo, "pColumns"))
                            Return True ; If Text is empty the return value is ignored
                        EndIf
                    Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button
                        $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                        _DebugPrint("$NM_CLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                                "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                                "-->Code:" & @TAB & $iCode & @CRLF & _
                                "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _
                                "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                                "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                                "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                                "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                                "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                                "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                                "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _
                                "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
    
    
                        Local $iIndex = DllStructGetData($tInfo, "Index"), $iState, $aResult2D, $iRows, $iColumns
                         $aItem = _GUICtrlListView_GetItemTextArray($hWndListView)
                        _SQLite_GetTable2d(-1, "SELECT * From MineralDB WHERE id='" & $aItem[1] & "'", $aResult2D, $iRows, $iColumns)
                        _UpdateGUI($aResult2D)
    
                    Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
                        $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                        _DebugPrint("$NM_DBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                                "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                                "-->Code:" & @TAB & $iCode & @CRLF & _
                                "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _
                                "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                                "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                                "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                                "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                                "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                                "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                                "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _
                                "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
                        ; No return value
                    Case $NM_KILLFOCUS ; The control has lost the input focus
                        _DebugPrint("$NM_KILLFOCUS" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                                "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                                "-->Code:" & @TAB & $iCode)
                        ; No return value
                    Case $NM_RCLICK ; Sent by a list-view control when the user clicks an item with the right mouse button
                        $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                        _DebugPrint("$NM_RCLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                                "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                                "-->Code:" & @TAB & $iCode & @CRLF & _
                                "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _
                                "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                                "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                                "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                                "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                                "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                                "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                                "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _
                                "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
                        ;Return 1 ; not to allow the default processing
                        Return 0 ; allow the default processing
                    Case $NM_RDBLCLK ; Sent by a list-view control when the user double-clicks an item with the right mouse button
                        $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                        _DebugPrint("$NM_RDBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                                "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                                "-->Code:" & @TAB & $iCode & @CRLF & _
                                "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _
                                "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                                "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                                "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                                "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                                "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                                "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                                "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _
                                "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
                        ; No return value
                    Case $NM_RETURN ; The control has the input focus and that the user has pressed the ENTER key
                        _DebugPrint("$NM_RETURN" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                                "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                                "-->Code:" & @TAB & $iCode)
    
    
                        $aItem = _GUICtrlListView_GetItemTextArray($hWndListView)
                        _SQLite_GetTable2d(-1, "SELECT * From MineralDB WHERE id='" & $aItem[1] & "'", $aResult2D, $iRows, $iColumns)
                        _UpdateGUI($aResult2D)
    
                    Case $NM_SETFOCUS ; The control has received the input focus
                        _DebugPrint("$NM_SETFOCUS" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                                "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                                "-->Code:" & @TAB & $iCode)
                        ; No return value
                EndSwitch
        EndSwitch
        Return $GUI_RUNDEFMSG
    EndFunc  ;==>WM_NOTIFY
    
    Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber)
        ConsoleWrite( _
                "!===========================================================" & @CRLF & _
                "+======================================================" & @CRLF & _
                "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _
                "+======================================================" & @CRLF)
    EndFunc  ;==>_DebugPrint
    
    Func _UpdateGUI($aResult2D)
        If UBound($aResult2D) >= 2 Then
        _query($aResult2D[1][0])
        $_test = $aResult2D[1][0]
        GUICtrlSetData($iptCount,$_test )
        $num = $_test
        ;Guisetstate(@SW_MINIMIZE,$hGui)
        Else
    
        EndIf
    Endfunc
    
    Func _ListView($QLite = "SELECT ROWID,* FROM MineralDB ORDER BY Name")
        _GUICtrlListView_DeleteAllItems($ListView)
        _SQLite_Query(-1, $QLite, $hQuery)
        While _SQLite_FetchData($hQuery, $aRow, False, False) = $SQLITE_OK
            _ArrayToString($aRow, '|', 1, 2)
    
        WEnd
        _SQLite_QueryFinalize($hQuery)
    EndFunc
    Alles anzeigen

    Ich habe gerade das Problem, dass sich das Script auf meinem Laptop nicht abspielen lässt. Ich verstehe es nicht, warum er keine .sqlite mehr erstellen kann (win8).

    Subscript used on non-accessible variable

    If $retarr[0] <> "" Then

    If $retarr^ ERROR steht in der Console. Beim anderen PC (Win7) kommt kein Fehler und die Datenbank funktioniert problemlos.

    VG

    Neight

  • dListview

    • Neight
    • 1. Juli 2019 um 17:45

    Hallo zusammen,

    die Daten sollen nach dem Namen sortiert werden und an ein Array gegeben werden.

    Das Listview besteht aus 3 Spalten. Das Array besteht denn aus 13 Elementen.

    Wie kann ich am Einfachsten Element 1 in Spalte 1 , Element 2 in Spalte 2 und in Spalte 3 Element 8 anzeigen lassen?

    Kann mir vielleicht jemand bei meinem Problem helfen?

    Code
    Func _UpdateGUI($QLite = "SELECT ROWID,* FROM MineralDB ORDER BY Name")
        _GUICtrlListView_DeleteAllItems($ListView)
        _SQLite_Query(-1, $QLite, $hQuery)
        While _SQLite_FetchData($hQuery, $aRow, False, False) = $SQLITE_OK
    ;~   _ArrayToString($aRow, '|', 1 , 9 )
      
      WEnd
        _SQLite_QueryFinalize($hQuery)
    EndFunc
  • Bilder SQL

    • Neight
    • 6. Mai 2018 um 14:17

    Danke euch beiden , ich werde mich nachher nochmal ransetzen und versuchen das um zusetzen. Ich hatte nen kleinen Denkfehler drin.

    Zeile 24 habe ich korrigiert, ganz übersehen^^

  • Bilder SQL

    • Neight
    • 6. Mai 2018 um 11:16

    Hey, ich tue mich irgendwie bei der Umsetzung ein bisschen schwer

  • Bilder SQL

    • Neight
    • 5. Mai 2018 um 23:11

    Hallo Leute,

    ich habe ein Problem beim Einfügen/Löschen von Bildern in der DB. Ich wollte den Namen des Bildes in die DB speichern und somit anzeigen lassen, abhängig von der jeweiligen ID. Ich hatte bisschen rum probiert , kam aber leider nicht ans Ziel. Vielleicht kann mir einer weiterhelfen bei meinem Problem?


    Gruß Neight

    C
    #include <ButtonConstants.au3>
    #include <ComboConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <SQLite.au3>
    #include <SQLite.dll.au3>
    
    
    
    
    Global $i , $g_hGUI, $g_hListView, $g_idGroupDropBox, $g_hGroupDropBox,$g_iLVOlColor, $aCtrlInput[$i]  , $g_iLVTextColor, $g_iLVBkColor
    Global $g_iGuiBkColor = 0x425357
    Global $dbn, $num = 1, $aStr[8]
    Global $aCtrlLabel[8], $aCtrlInput[8]
    
    Global Const $DB_Bilder = DirCreate(@ScriptDir & "\Bilder")
    
    _SQLite_Startup(@ScriptDir & "\sqlite3.dll", False, 1)
    
    
    _SQLite_Startup()
    If Not FileExists("MinealDB.sqlite") Then
        $dbn = _SQLite_Open("MineralDB.sqlite")
        _SQLite_Exec(-1, "CREATE TABLE MineralDB (ID INTEGER PRIMARY KEY AUTOINCREMENT, Name varchar(40) NOT NULL, Synonyme varchar(40) NOT NULL, Formel varchar(20), Farbe varchar(50), Dichte varchar(10), Härte varchar(10), Fundort varchar(40), Fundland varchar(40));")
    Else
        $dbn = _SQLite_Open("MineralDB.sqlite")
    EndIf
    
    
    
    #Region ### GUI section ###
    
    
        $g_hGUI = GUICreate("Mineraliendatenbank", 1144, 611, 249, 111, -1, BitOR($WS_EX_TOPMOST,$WS_EX_WINDOWEDGE))
        GUISetBkColor($g_iGuiBkColor)
    
    
        $g_idGroupDropBox = GUICtrlCreateGroup("", 66, 18, 1014, 510)
        GUICtrlCreateGroup("Name", 76, 28, 400, 40)
        $aCtrlInput[0] = GUICtrlCreateInput("", 79, 43, 386, 21)
    
        GUICtrlCreateGroup("Synonym", 76, 84, 400, 40)
        $aCtrlInput[1] = GUICtrlCreateInput("", 79, 99, 386, 21)
        GUICtrlCreateGroup("", -99, -99, 1, 1)
        GUICtrlCreateGroup("", -99, -99, 1, 1)
    
        GUICtrlCreateGroup("", -99, -99, 1, 1)
        GUICtrlCreateGroup("Allg. Eigenschaften", 76, 145, 396, 214)
        GUICtrlCreateGroup("Formel", 86, 165, 376, 40)
        $aCtrlInput[2] = GUICtrlCreateInput("", 89, 180, 370, 21)
        GUICtrlCreateGroup("", -99, -99, 1, 1)
    
        GUICtrlCreateGroup("Härte", 86, 309, 376, 40)
        $aCtrlInput[5] = GUICtrlCreateInput("", 89, 324, 370, 21)
        GUICtrlCreateGroup("", -99, -99, 1, 1)
        GUICtrlCreateGroup("", -99, -99, 1, 1)
    
        GUICtrlCreateGroup("Dichte", 86, 261, 376, 40)
        $aCtrlInput[4] = GUICtrlCreateInput("", 89, 276, 370, 21)
        GUICtrlCreateGroup("", -99, -99, 1, 1)
    
        GUICtrlCreateGroup("Farbe", 86, 213, 376, 40)
        $aCtrlInput[3] = GUICtrlCreateInput("", 89, 228, 370, 21)
        GUICtrlCreateGroup("", -99, -99, 1, 1)
    
    
    ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        GUICtrlCreateGroup("Funddaten", 76, 380, 400, 110)
        GUICtrlCreateGroup("Fundort", 86, 400, 380, 40)
        $aCtrlInput[6] = GUICtrlCreateInput("", 89, 415, 374, 21)
        GUICtrlCreateGroup("", -99, -99, 1, 1)
    
        GUICtrlCreateGroup("Fundland", 86, 440, 380, 40)
        $aCtrlInput[7] = GUICtrlCreateInput("", 89, 455, 374, 21)
        GUICtrlCreateGroup("", -99, -99, 1, 1)
        GUICtrlCreateGroup("", -99, -99, 1, 1)
    ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        $g_idPic = GUICtrlCreatePic("", 614, 44, 448, 318, BitOR($GUI_SS_DEFAULT_PIC,$SS_CENTERIMAGE,$SS_RIGHTJUST,$WS_BORDER))
        $g_idButton_LoadPic = GUICtrlCreateButton("Bild laden", 614, 385, 215, 33)
        $g_idButton_DeletePic = GUICtrlCreateButton("Bild löschen", 847, 385, 215, 33)
    ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    
        $Anzahl = GUICtrlCreateLabel("", 392, 592, 348, 17, BitOR($SS_SIMPLE, $SS_SUNKEN))
        $Label2 = GUICtrlCreateLabel("", 0, 592, 380, 17, BitOR($SS_SIMPLE, $SS_SUNKEN))
        $Label3 = GUICtrlCreateLabel("", 752, 592, 389, 17, BitOR($SS_SIMPLE, $SS_SUNKEN))
    
    
        $btnAdd = GUICtrlCreateButton("+", 16, 48, 33, 33)
        $btnDel = GUICtrlCreateButton("-", 16, 88, 33, 33)
    
    ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        $g_idButton_Zurueck = GUICtrlCreateButton("Zurück", 90, 554, 430, 33)
        $g_idButton_Weiter  = GUICtrlCreateButton("Weiter", 618, 554, 430, 33)
    
        $iptCount = GUICtrlCreateInput($num, 536, 560, 65, 21, BitOR($ES_AUTOHSCROLL, $ES_READONLY,$ES_CENTER))
    
        GUISetState(@SW_SHOW)
    
    #EndRegion ### START GUI section ###
    
    _query($num)
    _SQLite_CountRows('MineralDB')
    
    
    While True
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                _quit()
            Case $g_idButton_Weiter
                $num += 1
                GUICtrlSetData($iptCount, $num)
                _query($num)
            Case $g_idButton_Zurueck
                If $num == 1 Then
                    $num = 1
                    GUICtrlSetData($iptCount, $num)
                Else
                    $num -= 1
                    GUICtrlSetData($iptCount, $num)
                    _query($num)
                EndIf
            Case $btnAdd
                If GUICtrlRead($aCtrlInput[0]) == "" Then
                    MsgBox(0, "ERORR", "Empty name!")
    
                Else
                    _add($num)
                EndIf
            Case $btnDel
                _del($num)
            Case $g_idButton_LoadPic
                 $pic = FileOpenDialog("Wähle ein Bild aus!", @ScriptDir & "\Bilder" , "Bilder (*.jpg;*.bmp;*.png)", 1 + 2)
                If @error Then
                    MsgBox(4096, "", "Keine Datei(en) ausgewählt")
                Else
    
    
                Endif
        EndSwitch
    WEnd
    
    
    Func _quit()
        _SQLite_Close()
        _SQLite_Shutdown()
        Exit
    EndFunc
    
    
    Func _query($id)
        _clear()
        Local $retarr
        If _SQLite_QuerySingleRow($dbn, "SELECT * FROM MineralDB WHERE id='" & $id & "'", $retarr) == $SQLITE_OK Then
            If $retarr[0] == "" Then
                MsgBox(0, "ERROR", "Query error!")
            Else
                For $l = 0 To 7
                    GUICtrlSetData($aCtrlInput[$l], $retarr[$l + 1])
                Next
            EndIf
        EndIf
    EndFunc
    
    
    Func _add($id)
        _readipt()
        Local $retarr
        _SQLite_QuerySingleRow($dbn, "SELECT id FROM MineralDB WHERE id='" & $id & "'", $retarr)
        If $retarr[0] <> "" Then
            _SQLite_Exec($dbn, "UPDATE MineralDB SET Name='" _
                     & $aStr[0] & "', Synonyme='" & $aStr[1] & "',Formel='" & $aStr[2] & "',Farbe='" & $aStr[3] & "',Dichte='" & $aStr[4] _
                     & "',Härte='" & $aStr[5] & "',Fundort='" & $aStr[6] & "',Fundland='" & $aStr[7] & "' WHERE id='" & $id & "'")
        Else
            _SQLite_Exec($dbn, "INSERT INTO MineralDB (ID,Name,Synonyme,Formel,Farbe,Dichte,Härte,Fundort,Fundland) VALUES ('" _
                     & $num & "','" & $aStr[0] & "','" & $aStr[1] & "','" & $aStr[2] _
                     & "','" & $aStr[3] & "','" & $aStr[4] & "','" & $aStr[5] & "','" _
                     & $aStr[6] & "','" & $aStr[7] & "');")
        EndIf
        _SQLite_CountRows('MineralDB')
    EndFunc
    
    
    Func _del($id)
        _clear()
        Local $retarr
        _SQLite_QuerySingleRow($dbn, "SELECT id FROM MineralDB WHERE id='" & $id & "'", $retarr)
        If $retarr[0] <> "" Then
            _SQLite_Exec($dbn, "DELETE FROM MineralDB WHERE id='" & $id & "'")
        EndIf
        _SQLite_CountRows('MineralDB')
    EndFunc
    
    
    Func _clear()
        For $j = 0 To 7
            GUICtrlSetData($aCtrlInput[$j], "")
        Next
    EndFunc
    
    
    Func _readipt()
        For $k = 0 To 7
            $aStr[$k] = GUICtrlRead($aCtrlInput[$k])
        Next
    EndFunc
    
    
    Func _SQLite_CountRows($_sTable)
        Local $hQuery, $aQuery, $iRet = 0, $iErr
        If $SQLITE_OK <> _SQLite_Query(-1, "SELECT count(*) FROM " & $_sTable & ";", $hQuery) Then
            $iErr = _SQLite_ErrCode()
            _SQLite_QueryFinalize($hQuery)
            Return SetError(1, $iErr, -1)
        EndIf
        While _SQLite_FetchData($hQuery, $aQuery) = $SQLITE_OK
            $iRet = $aQuery[0]
        WEnd
        _SQLite_QueryFinalize($hQuery)
        GUICtrlSetData($Anzahl, " Anzahl der Datensätze: " & $iRet)
    EndFunc
    Alles anzeigen
  • Listview, Sqlite

    • Neight
    • 27. November 2016 um 16:49

    ja da hast du wohl Recht.
    Das meinte ich mit pausieren, erstmal sich noch paar Grundlagen angucken und denn mal gucken ob und wie es weiter geht mit dem Projekt.

    Ich werde es mir mal angucken, vielleicht hilft es mir weiter.

    Neight

  • Listview, Sqlite

    • Neight
    • 27. November 2016 um 16:07

    Hey Bitnugger,

    danke für deine Hilfe und Zeit bei der Bearbeitung des Scripts.

    Ja ich merke auch, dass das Projekt doch recht schwierig ist. Mal gucken vielleicht muss ich es erstmal pausieren, weil es schon noch paar Dinge gibt, wo ich nicht genau weiß wie ich es umsetze.

  • Listview, Sqlite

    • Neight
    • 27. November 2016 um 15:01

    Hey,

    Vielen Dank Euch beiden für eure Hilfe. Ich werde es versuchen umzusetzen.

  • Listview, Sqlite

    • Neight
    • 27. November 2016 um 13:03

    Hallo Leute,

    ich habe ein Problem beim Einfügen von neuen Datensätzen in die Sqlite Datenbank. Ich habe ein vorläufiges Gui - Fenster zum Neueinfügen gemacht. Kann mir vielleicht einer zeigen, wie ich es am Besten umsetzen kann?

    Ich bräuchte noch eine Idee, wie man durch das Anklicken der Einträge im Listview, rechts die jeweiligen passenden Felder ausgefüllt werden.

    Wäre das eine Möglichkeit zum Anklicken _GUICtrlListView_ClickItem


    Gruß

    Neight

    C
    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <ListViewConstants.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <SQLite.au3>
    #include <GuiListView.au3>
    #include <ComboConstants.au3>
    #include <SQLite.dll.au3>
    
    
    Global Const $sDbMineral = @ScriptDir & "\mineraldb.sqlite"
    Global $hDB, $iRval, $aResult, $iRows, $iColumns, $DB, $QLite,$pic
    
    
    
    
    #Region ### START Koda GUI section ### Form=
    $Form1_1 = GUICreate("Mineraliendatenbank", 1181, 736, 214, 142)
    $MenuItem3 = GUICtrlCreateMenu("&File")
    $MenuItem4 = GUICtrlCreateMenuItem("New"&@TAB&"Ctrl+Down", $MenuItem3)
    $MenuItem5 = GUICtrlCreateMenuItem("Open"&@TAB&"", $MenuItem3)
    $MenuItem6 = GUICtrlCreateMenuItem("Save"&@TAB&"Shift+Ctrl+0", $MenuItem3)
    $MenuItem7 = GUICtrlCreateMenuItem("Exit"&@TAB&"", $MenuItem3)
    $MenuItem2 = GUICtrlCreateMenu("&Edit")
    $MenuItem9 = GUICtrlCreateMenuItem("Delete"&@TAB&"", $MenuItem2)
    $MenuItem1 = GUICtrlCreateMenu("&Help")
    $MenuItem8 = GUICtrlCreateMenuItem("About"&@TAB&"", $MenuItem1)
    GUISetBkColor(0xB9D1EA)
    $Group1 = GUICtrlCreateGroup("", 176, 80, 945, 553)
    GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
    $Label1 = GUICtrlCreateLabel("Nummer", 224, 128, 55, 20)
    $Nummer = GUICtrlCreateInput("", 296, 128, 41, 24)
    $Label2 = GUICtrlCreateLabel("Name", 384, 128, 41, 20)
    $Name = GUICtrlCreateInput("", 440, 128, 177, 24)
    $Group2 = GUICtrlCreateGroup("allg. Eigenschaften", 208, 192, 401, 177)
    $Label3 = GUICtrlCreateLabel("Formel", 224, 224, 46, 20)
    $Formel = GUICtrlCreateInput("", 280, 224, 105, 24)
    $Label4 = GUICtrlCreateLabel("Gewicht", 224, 264, 51, 20)
    $Gewicht = GUICtrlCreateInput("", 280, 264, 105, 24)
    $Farbe = GUICtrlCreateLabel("Farbe", 224, 304, 40, 20)
    $Farb = GUICtrlCreateInput("", 280, 304, 105, 24)
    $Label5 = GUICtrlCreateLabel("Radioaktiv", 400, 224, 69, 20)
    $Checkbox1 = GUICtrlCreateCheckbox("Ja", 480, 224, 41, 17)
    $Checkbox2 = GUICtrlCreateCheckbox("Nein", 544, 224, 41, 17)
    $Label6 = GUICtrlCreateLabel("Magnetisch", 400, 256, 73, 20)
    $Ja = GUICtrlCreateCheckbox("Ja", 480, 256, 49, 17)
    $Nein = GUICtrlCreateCheckbox("Nein", 544, 256, 49, 17)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $pic = GUICtrlCreatePic("", 640, 112, 441, 305, BitOR($GUI_SS_DEFAULT_PIC,$SS_RIGHTJUST,$WS_BORDER))
    $Group3 = GUICtrlCreateGroup("Funddaten", 208, 416, 409, 153)
    $Fundor = GUICtrlCreateLabel("Fundort", 224, 456, 49, 20)
    $Fundort = GUICtrlCreateInput("", 304, 456, 241, 24)
    $Fundlan = GUICtrlCreateInput("", 304, 504, 241, 24)
    $Fundland = GUICtrlCreateLabel("Fundland", 224, 504, 60, 20)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Button1 = GUICtrlCreateButton("Bild öffnen", 744, 424, 97, 33)
    $Button2 = GUICtrlCreateButton("Bild löschen", 880, 424, 97, 33)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    GUICtrlCreateInput("", 312, 24, 465, 21)
    $Suche = GUICtrlCreateLabel("Suche", 256, 24, 55, 24)
    GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
    $Zurueck = GUICtrlCreateButton("Zurück", 440, 648, 65, 33)
    $Vor = GUICtrlCreateButton("Vor", 696, 648, 65, 33)
    
    
    $ListView1 = GUICtrlCreateListView("", 8, 88, 150, 545)
    _GUICtrlListView_AddColumn($ListView1, "Name", 70)
    _GUICtrlListView_AddColumn($ListView1, "Nummer", 150)
    ;Global $aHeader = StringSplit($ListView1, '|')
    Global $hListView = GUICtrlGetHandle($ListView1)
    $cContextMenue = GUICtrlCreateContextMenu($ListView1)
    GUICtrlCreateListViewItem("",$ListView1)
    ;Dim $Form1_1_AccelTable[2][2] = [["^{DOWN}", $MenuItem4],["^+0", $MenuItem6]]
    ;GUISetAccelerators($Form1_1_AccelTable)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###
    
    
    
    
    
    
    
    
    _SQLite_Startup()
    If @error Then Exit MsgBox(16, "SQLite Fehler", "SQLite.dll konnte nicht geladen werden!")
    ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)
    Global $hDB = _SQLite_Open($sDbMineral)
    If @error Then Exit MsgBox(16, "SQLite Fehler", "Die Datenbank kann nicht geöffnet werden!")
    
    
    If FileExists("mineraldb.sqlite") Then
    	$DB = _SQLite_Open("mineraldb.sqlite")
    	If @error Then Exit MsgBox(16, "SQLite Fehler", "Die Datenbank kann nicht geöffnet werden!")
    
    
    	_SQLite_Exec(-1, "CREATE TABLE IF NOT EXISTS Mineralien (Nummer INTEGER PRIMARY KEY,Name TEXT,Formel TEXT,Gewicht TEXT,Farbe TEXT,Fundort TEXT,Fundland TEXT);")
    
    
    	_SQLite_Exec(-1, "INSERT INTO Mineralien(Nummer,Name,Formel,Gewicht,Farbe,Fundort,Fundland) VALUES ('1', 'xxx', 'Dhgdgd', '500', 'XXX', 'Hier', 'hier');")
    	_SQLite_Exec(-1, "INSERT INTO Mineralien(Nummer,Name,Formel,Gewicht,Farbe,Fundort,Fundland) VALUES ('2', 'xxxx', 'Dhgdgd', '500', 'XXX', 'Hier', 'hier');")
    
    
    Endif
    
    
    
    
    While True
    	Switch GUIGetMsg()
    		Case -3
    			_SQLite_Close($DB)
    			_SQLite_Shutdown()
    			Exit
    
    
    		Case $MenuItem5
    
    
    			$iRva = _SQLite_GetTable2d(-1, "SELECT Nummer, * FROM Mineralien;", $aResult, $iRows, $iColumns)
    					_SQLite_GetTable2d(-1, "SELECT Name, * FROM Mineralien;", $aResult, $iRows, $iColumns)
    					_ArrayDelete($aResult,0)
    					_GUICtrlListView_AddArray($ListView1, $aResult)
    
    
    
    
    
    
    		Case $MenuItem4
    			_NeuerDatensatz()
    
    
    
    
    		Case $Button1
                    $open = FileOpenDialog("Wählen Sie eine Datei aus.", @TempDir, "Bilder (*.jpg;*.bmp;*.png)")
    				If @error Then
    					MsgBox(4096, "", "Keine Datei ausgewählt")
    				Endif
    
    
    				GUICtrlSetImage($pic,$open)
    
    
    		Case $MenuItem7
    			Exit
    
    
    
    
    
    
    EndSwitch
    WEnd
    
    
    
    
    
    
    
    
    Func _NeuerDatensatz()
    
    
    #Region ### START Koda GUI section ### Form=
    $XXX = GUICreate("Neuer Datensatz", 530, 241, 192, 131)
    $Nummer = GUICtrlCreateInput("Nummer", 24, 56, 121, 21)
    $Input2 = GUICtrlCreateInput("Formel", 24, 104, 121, 21)
    $Input3 = GUICtrlCreateInput("Farbe", 24, 152, 121, 21)
    $Input4 = GUICtrlCreateInput("Name", 200, 56, 121, 21)
    $Input5 = GUICtrlCreateInput("Gewicht", 200, 104, 121, 21)
    $Input6 = GUICtrlCreateInput("Fundort", 200, 152, 121, 21)
    $Input1 = GUICtrlCreateInput("Fundland", 376, 56, 121, 21)
    $Bitte = GUICtrlCreateLabel("Bitte alle Felder ausfüllen!", 40, 16, 129, 17)
    $OK = GUICtrlCreateButton("OK", 168, 192, 169, 33)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###
    
    
    While 1
    	$nMsg = GUIGetMsg()
    	Switch $nMsg
    		Case $GUI_EVENT_CLOSE
    			Exit
    
    
    		Case $OK
    		_SQLite_Exec(-1, "INSERT INTO Mineralien (Nummer,Name,Formel,Gewicht,Farbe,Fundort,Fundland) VALUES ('"_
    		& GUICtrlRead($Nummer[1]) & "','" & GUICtrlRead($Input4[2]) & "','" & GUICtrlRead($Input2[3]) & "','" & GUICtrlRead($Input5[4]) & "','" & GUICtrlRead($Input3[5])& "','" & GUICtrlRead($Input6[6])& "','" & GUICtrlRead($Input1[7]) & "');")
    
    
    
    
    
    
    	EndSwitch
    WEnd
    
    
    
    
    Endfunc
    Alles anzeigen
  • Datenbank , guilistview

    • Neight
    • 6. November 2016 um 02:01

    okay vielen Dank, weil ich habe das Problem das er die Ergebnisse der falschen Spalte zuordnet.

  • Datenbank , guilistview

    • Neight
    • 5. November 2016 um 17:22

    Hätte einer eine Idee wie man die Wiedergabe des Arrays in der Liste richtig ordnet und nur die Ergebnisse wiedergeben werden ohne Tabellennamen.

    Neight

  • Datenbank , guilistview

    • Neight
    • 27. Oktober 2016 um 19:59

    okay danke, ich werde mir die Beispiele mal angucken.
    Ich bin ein Stück weiter gekommen.

    Code
    Global Const $sDbMineral = @ScriptDir & "\mineraldb.sqlite"
    Global $hDB, $iRval, $aResult, $iRows, $iColumns, $DB, $QLite
    #Region ### START Koda GUI section ### Form=
    $Form1_1 = GUICreate("Mineraliendatenbank", 1181, 736, 214, 142)
    $MenuItem3 = GUICtrlCreateMenu("&File")
    $MenuItem4 = GUICtrlCreateMenuItem("New"&@TAB&"Ctrl+Down", $MenuItem3)
    $MenuItem5 = GUICtrlCreateMenuItem("Open"&@TAB&"", $MenuItem3)
    $MenuItem6 = GUICtrlCreateMenuItem("Save"&@TAB&"Shift+Ctrl+0", $MenuItem3)
    $MenuItem7 = GUICtrlCreateMenuItem("Exit"&@TAB&"", $MenuItem3)
    $MenuItem2 = GUICtrlCreateMenu("&Edit")
    $MenuItem9 = GUICtrlCreateMenuItem("Delete"&@TAB&"", $MenuItem2)
    $MenuItem1 = GUICtrlCreateMenu("&Help")
    $MenuItem8 = GUICtrlCreateMenuItem("About"&@TAB&"", $MenuItem1)
    GUISetBkColor(0xB9D1EA)
    $Group1 = GUICtrlCreateGroup("", 176, 80, 945, 553)
    GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
    $Label1 = GUICtrlCreateLabel("Nummer", 224, 128, 55, 20)
    $Nummer = GUICtrlCreateInput("", 296, 128, 41, 24)
    $Label2 = GUICtrlCreateLabel("Name", 384, 128, 41, 20)
    $Name = GUICtrlCreateInput("", 440, 128, 177, 24)
    $Group2 = GUICtrlCreateGroup("allg. Eigenschaften", 208, 192, 401, 177)
    $Label3 = GUICtrlCreateLabel("Formel", 224, 224, 46, 20)
    $Formel = GUICtrlCreateInput("", 280, 224, 105, 24)
    $Label4 = GUICtrlCreateLabel("Gewicht", 224, 264, 51, 20)
    $Gewicht = GUICtrlCreateInput("", 280, 264, 105, 24)
    $Farbe = GUICtrlCreateLabel("Farbe", 224, 304, 40, 20)
    $Farb = GUICtrlCreateInput("", 280, 304, 105, 24)
    $Label5 = GUICtrlCreateLabel("Radioaktiv", 400, 224, 69, 20)
    $Checkbox1 = GUICtrlCreateCheckbox("Ja", 480, 224, 41, 17)
    $Checkbox2 = GUICtrlCreateCheckbox("Nein", 544, 224, 41, 17)
    $Label6 = GUICtrlCreateLabel("Magnetisch", 400, 256, 73, 20)
    $Ja = GUICtrlCreateCheckbox("Ja", 480, 256, 49, 17)
    $Nein = GUICtrlCreateCheckbox("Nein", 544, 256, 49, 17)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $pic = GUICtrlCreatePic("", 640, 112, 441, 305, BitOR($GUI_SS_DEFAULT_PIC,$SS_RIGHTJUST,$WS_BORDER))
    $Group3 = GUICtrlCreateGroup("Funddaten", 208, 416, 409, 153)
    $Fundor = GUICtrlCreateLabel("Fundort", 224, 456, 49, 20)
    $Fundort = GUICtrlCreateInput("", 304, 456, 241, 24)
    $Fundlan = GUICtrlCreateInput("", 304, 504, 241, 24)
    $Fundland = GUICtrlCreateLabel("Fundland", 224, 504, 60, 20)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Button1 = GUICtrlCreateButton("Bild öffnen", 744, 424, 97, 33)
    $Button2 = GUICtrlCreateButton("Bild löschen", 880, 424, 97, 33)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    GUICtrlCreateInput("", 312, 24, 465, 21)
    $Suche = GUICtrlCreateLabel("Suche", 256, 24, 55, 24)
    GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
    $Zurueck = GUICtrlCreateButton("Zurück", 440, 648, 65, 33)
    $Vor = GUICtrlCreateButton("Vor", 696, 648, 65, 33)
    $ListView1 = GUICtrlCreateListView("", 8, 88, 150, 545)
    _GUICtrlListView_AddColumn($ListView1, "Nummer", 70)
    _GUICtrlListView_AddColumn($ListView1, "Name", 150)
    ;Global $aHeader = StringSplit($ListView1, '|')
    Global $hListView = GUICtrlGetHandle($ListView1)
    $cContextMenue = GUICtrlCreateContextMenu($ListView1)
    GUICtrlCreateListViewItem("",$ListView1)
    ;Dim $Form1_1_AccelTable[2][2] = [["^{DOWN}", $MenuItem4],["^+0", $MenuItem6]]
    ;GUISetAccelerators($Form1_1_AccelTable)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###
    _SQLite_Startup()
    If @error Then Exit MsgBox(16, "SQLite Fehler", "SQLite.dll konnte nicht geladen werden!")
    ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)
    Global $hDB = _SQLite_Open($sDbMineral)
    If @error Then Exit MsgBox(16, "SQLite Fehler", "Die Datenbank kann nicht geöffnet werden!")
    If FileExists("mineraldb.sqlite") Then
    	$DB = _SQLite_Open("mineraldb.sqlite")
    	If @error Then Exit MsgBox(16, "SQLite Fehler", "Die Datenbank kann nicht geöffnet werden!")
    	_SQLite_Exec(-1, "CREATE TABLE IF NOT EXISTS Mineralien (Nummer INTEGER PRIMARY KEY,Name TEXT,Formel TEXT,Gewicht TEXT,Farbe TEXT,Fundort TEXT,Fundland TEXT);")
    	_SQLite_Exec(-1, "INSERT INTO Mineralien(Nummer,Name,Formel,Gewicht,Farbe,Fundort,Fundland) VALUES ('1', 'xxx', 'Dhgdgd', '500', 'XXX', 'Hier', 'hier');")
    	_SQLite_Exec(-1, "INSERT INTO Mineralien(Nummer,Name,Formel,Gewicht,Farbe,Fundort,Fundland) VALUES ('2', 'xxxx', 'Dhgdgd', '500', 'XXX', 'Hier', 'hier');")
    Endif
    While True
    	Switch GUIGetMsg()
    		Case -3
    			_SQLite_Close($DB)
    			_SQLite_Shutdown()
    			Exit
    		Case $MenuItem5
    			$iRval = _SQLite_GetTable2d(-1, "SELECT Nummer, * FROM Mineralien;", $aResult, $iRows, $iColumns)
    					 _SQLite_GetTable2d(-1, "SELECT Name, * FROM Mineralien;", $aResult, $iRows, $iColumns)
     					_GUICtrlListView_AddArray($ListView1, $aResult)
    EndSwitch
    WEnd
    Alles anzeigen
  • Datenbank , guilistview

    • Neight
    • 27. Oktober 2016 um 16:27

    Hallo, ich habe wieder angefangen mich mit Autoit zu beschäftigen. Ich will eine Datenbank mit Sqlite erstellen und diese über das Gui fenster auslesen.
    Links in der Tabelle (im GUI fenster) soll jeweils die Nummer und der jeweilige Name angezeigt werden. Ich weiß nicht wie ich das verknüpfen soll. Außerdem habe ich ein Problem beim Erstellen der Sqlite Datei.

    Danke im vorraus wenn einer einen Rat hat.

    Neight

    (Der jeweilige rechte Teil wird durch auswählen des Namens in der Tabelle angezeigt. )

    Code
    Global $hDB, $iRval
    
    
    #Region ### START Koda GUI section ### Form=
    $Form1_1 = GUICreate("Mineraliendatenbank", 1181, 736, 214, 142)
    $MenuItem3 = GUICtrlCreateMenu("&File")
    $MenuItem4 = GUICtrlCreateMenuItem("New"&@TAB&"Ctrl+Down", $MenuItem3)
    $MenuItem5 = GUICtrlCreateMenuItem("Open"&@TAB&"", $MenuItem3)
    $MenuItem6 = GUICtrlCreateMenuItem("Save"&@TAB&"Shift+Ctrl+0", $MenuItem3)
    $MenuItem7 = GUICtrlCreateMenuItem("Exit"&@TAB&"", $MenuItem3)
    $MenuItem2 = GUICtrlCreateMenu("&Edit")
    $MenuItem9 = GUICtrlCreateMenuItem("Delete"&@TAB&"", $MenuItem2)
    $MenuItem1 = GUICtrlCreateMenu("&Help")
    $MenuItem8 = GUICtrlCreateMenuItem("About"&@TAB&"", $MenuItem1)
    GUISetBkColor(0xB9D1EA)
    $Group1 = GUICtrlCreateGroup("", 176, 80, 945, 553)
    GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
    $Label1 = GUICtrlCreateLabel("Nummer", 224, 128, 55, 20)
    $Nummer = GUICtrlCreateInput("", 296, 128, 41, 24)
    $Label2 = GUICtrlCreateLabel("Name", 384, 128, 41, 20)
    $Name = GUICtrlCreateInput("", 440, 128, 177, 24)
    $Group2 = GUICtrlCreateGroup("allg. Eigenschaften", 208, 192, 401, 177)
    $Label3 = GUICtrlCreateLabel("Formel", 224, 224, 46, 20)
    $Formel = GUICtrlCreateInput("", 280, 224, 105, 24)
    $Label4 = GUICtrlCreateLabel("Gewicht", 224, 264, 51, 20)
    $Gewicht = GUICtrlCreateInput("", 280, 264, 105, 24)
    $Farbe = GUICtrlCreateLabel("Farbe", 224, 304, 40, 20)
    $Farb = GUICtrlCreateInput("", 280, 304, 105, 24)
    $Label5 = GUICtrlCreateLabel("Radioaktiv", 400, 224, 69, 20)
    $Checkbox1 = GUICtrlCreateCheckbox("Ja", 480, 224, 41, 17)
    $Checkbox2 = GUICtrlCreateCheckbox("Nein", 544, 224, 41, 17)
    $Label6 = GUICtrlCreateLabel("Magnetisch", 400, 256, 73, 20)
    $Ja = GUICtrlCreateCheckbox("Ja", 480, 256, 49, 17)
    $Nein = GUICtrlCreateCheckbox("Nein", 544, 256, 49, 17)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $pic = GUICtrlCreatePic("", 640, 112, 441, 305, BitOR($GUI_SS_DEFAULT_PIC,$SS_RIGHTJUST,$WS_BORDER))
    $Group3 = GUICtrlCreateGroup("Funddaten", 208, 416, 409, 153)
    $Fundor = GUICtrlCreateLabel("Fundort", 224, 456, 49, 20)
    $Fundort = GUICtrlCreateInput("", 304, 456, 241, 24)
    $Fundlan = GUICtrlCreateInput("", 304, 504, 241, 24)
    $Fundland = GUICtrlCreateLabel("Fundland", 224, 504, 60, 20)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Button1 = GUICtrlCreateButton("Bild öffnen", 744, 424, 97, 33)
    $Button2 = GUICtrlCreateButton("Bild löschen", 880, 424, 97, 33)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    GUICtrlCreateInput("", 312, 24, 465, 21)
    $Suche = GUICtrlCreateLabel("Suche", 256, 24, 55, 24)
    GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
    $Zurueck = GUICtrlCreateButton("Zurück", 440, 648, 65, 33)
    $Vor = GUICtrlCreateButton("Vor", 696, 648, 65, 33)
    
    
    $ListView1 = GUICtrlCreateListView("Nr.      |   Mineralien", 8, 88, 150, 545)
    Global $aHeader = StringSplit($ListView1, '|')
    Global $hListView = GUICtrlGetHandle($ListView1)
    $cContextMenue = GUICtrlCreateContextMenu($ListView1)
    GUICtrlCreateListViewItem("",$ListView1)
    ;Dim $Form1_1_AccelTable[2][2] = [["^{DOWN}", $MenuItem4],["^+0", $MenuItem6]]
    ;GUISetAccelerators($Form1_1_AccelTable)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###
    
    
    
    
    
    
    
    
    _SQLite_Startup(@ScriptDir & "\sqlite3.dll", False, 1)
    If @error Then Exit MsgBox(16, "SQLite Fehler", "SQLite.dll konnte nicht geladen werden!")
    
    
    ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)
    
    
    If FileExists("mineraldb.sqlite") Then
    	$DB = _SQLite_Open("mineraldb.sqlite")
    	If @error Then Exit MsgBox(16, "SQLite Fehler", "Die Datenbank kann nicht geöffnet werden!")
    
    
    Else
    	$DB = _SQLite_Open(@ScriptDir & "\mineraldb.sqlite")
    	If @error Then Exit MsgBox(16, "SQLite Fehler", "Die Datenbank kann nicht geöffnet werden!")
    
    
    	_SQLite_Exec($DB, "CREATE TABLE Mineralien (Nummer INTEGER PRIMARY KEY,Name TEXT,Formel TEXT,Gewicht TEXT,Farbe TEXT,Fundort TEXT,Fundland TEXT);")
    
    
    	_SQLite_Exec(-1, "INSERT INTO Mineralien(Nummer,Name,Formel,Gewicht,Farbe,Fundort,Fundland) VALUES ('1', 'xxx', 'Dhgdgd', '500', 'XXX', 'Hier', 'hier');")
    
    
    Endif
    
    
    
    
    _SQLite_Close()
    _SQLite_Shutdown()
    Alles anzeigen

Spenden

Jeder Euro hilft uns, Euch zu helfen.

Download

AutoIt Tutorial
AutoIt Buch
Onlinehilfe
AutoIt Entwickler
  1. Datenschutzerklärung
  2. Impressum
  3. Shoutbox-Archiv
Community-Software: WoltLab Suite™