Access DB in listview in Editbox darstellen

  • Hallo,

    Habe einen Access DB:
    Wo ich aus einer bestimmten Tabele mit verschieden Feldern.
    Infos in einer Gui darstellen will
    den anfang habe ich gemacht komme aber nicht weiter.

    Ich kann zur zeit aus der Tabele lesen und den inhalt von feld 1auslesen

    1.wie kann ich das in die Listview[0] Schreiben?(Als Consolewrite geht es)
    2.Wenn ich die Items in der Listview[0] habe und dort ein item anklicke,
    wie kann ich dann aus den anderen feldern die info in die Listview schreiben bzw. editbox.
    Geht mir eigentlich haupsächlich um das lesen der entsprechenden "feldnamen"


    Spoiler anzeigen
    [autoit]

    #include <File.au3>
    #include <GUIConstantsEx.au3>
    #include <GuiListView.au3>
    #include <ListViewConstants.au3>
    #include <WindowsConstants.au3>
    global $dbname = @ScriptDir & "\OPTM CISM_be.mdb" ; Datenbankpfad und Datei-/Datenbankname
    global $tblname = "tbl_Incident"
    Global $fldname = "Task_Aufgabenname"
    Global $format = "Text(50)"
    Global $data = "Blah Blah Blah"
    Global $ListView[9]
    Global $sDir = @ScriptDir & '\csv\'
    Global $aFiles = _FileListToArray($sDir, '*.csv', 1), $sComboFiles
    If Not @error Then
    For $i = 1 To $aFiles[0]
    $sComboFiles &= $aFiles[$i] & '|'
    Next
    $sComboFiles = StringTrimRight($sComboFiles, 1)
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    #Region ### START Koda GUI section ### Form=F:\autoit\entwicklung\CISM\Form1.kxf
    $Form1 = GUICreate("BMC", 949, 555, 197, 277)
    $ListView[0] = GUICtrlCreateListView("1 Short decription", 32, 96, 234, 422)
    GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 80)
    ;$Combo1 = GUICtrlCreateCombo("Combo1", 32, 16, 233, 25)
    $Combo2 = GUICtrlCreateCombo("Liste Auswählen", 32, 72, 233, 25)
    GUICtrlSetData(-1, $sComboFiles)
    ;$Inputun = GUICtrlCreateInput("", 32, 32, 151, 21)
    ;GUICtrlCreateLabel("Caller ", 32, 10, 60, 20)
    ;$Input2 = GUICtrlCreateInput("Input1", 449, 16, 143, 21)
    ;$Input3 = GUICtrlCreateInput("Input1", 601, 16, 143, 21)
    ;$Input4 = GUICtrlCreateInput("Input1", 286, 50, 151, 21)
    ;$Input5 = GUICtrlCreateInput("Input1", 446, 50, 143, 21)
    ;$Input6 = GUICtrlCreateInput("Input1", 598, 50, 143, 21)
    ;$Input7 = GUICtrlCreateInput("Input1", 755, 20, 143, 21)
    ;$Input8 = GUICtrlCreateInput("Input1", 759, 49, 143, 21)
    ;$ListView[1] = GUICtrlCreateListView("2 Detail", 273, 96, 294, 211)
    $ListView[1] = GUICtrlCreateEdit("2 Detail", 273, 96, 294, 211)
    GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 280)
    ;$ListView[2] = GUICtrlCreateListView("3 Way of Solution ", 273, 305, 294, 211)
    $ListView[2] = GUICtrlCreateEdit("3 Way of Solution ", 273, 305, 294, 211)
    GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 280)

    [/autoit] [autoit][/autoit] [autoit]

    $ListView[3] = GUICtrlCreateListView("4 Classification", 572, 95, 146, 54)
    GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 140)

    [/autoit] [autoit][/autoit] [autoit]

    $ListView[4] = GUICtrlCreateListView("5 Compnent Type", 572, 150, 146, 54)

    [/autoit] [autoit][/autoit] [autoit]

    GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 140)
    $ListView[5] = GUICtrlCreateListView("6 Component", 572, 200, 146, 54)
    GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 80)

    [/autoit] [autoit][/autoit] [autoit]

    $ListView[6] = GUICtrlCreateListView("7 Assined To Group", 572, 305, 146, 55)
    GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 80)
    $ListView[7] = GUICtrlCreateListView("8 Submitter Group", 572, 369, 146, 54)
    GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 80)

    [/autoit] [autoit][/autoit] [autoit]

    $ListView[8] = GUICtrlCreateListView("9 Client", 572, 420, 146, 54)
    GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 80)
    ;$Userladen = GUICtrlCreateButton("Userladen", 800, 75, 75, 17, $WS_GROUP)
    ;$Userdel = GUICtrlCreateButton("löschen", 800, 58, 75, 17, $WS_GROUP)
    $Dbread = GUICtrlCreateButton("DB Lesen", 50, 520, 75, 17, $WS_GROUP)
    ;$ListView10 = GUICtrlCreateListView("UserID|im Ad vorhanden", 750, 96, 186, 422)
    ;GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 80)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    GUISetState(@SW_SHOW)

    [/autoit] [autoit][/autoit] [autoit]

    #EndRegion ### END Koda GUI section ###

    [/autoit] [autoit][/autoit] [autoit]

    ;GUICtrlSetData($Inputun, $user2)
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    case $Dbread
    $test = _ReadOneFld($tblname, $dbname, $fldname)
    ConsoleWrite($test)
    GUICtrlCreateListViewItem($test, $ListView[1])
    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _ReadOneFld($_sql, $_dbname, $_field)
    Dim $_output
    $adoCon = ObjCreate ("ADODB.Connection")
    $adoCon.Open ("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $_dbname)
    $adoRs = ObjCreate ("ADODB.Recordset")
    $adoRs.CursorType = 1
    $adoRs.LockType = 3
    $adoRs.Open ($_sql, $adoCon)

    [/autoit] [autoit][/autoit] [autoit]

    With $adoRs
    If .RecordCount Then
    While Not .EOF
    $_output = $_output & .Fields ($_field).Value & @CRLF
    .MoveNext
    WEnd
    EndIf
    EndWith
    $adoCon.Close
    Return $_output
    EndFunc

    [/autoit]

    lg SubZero ;)
    ==========================================================================

    "Der Computer ist die logische Weiterentwicklung des Menschen: Intelligenz ohne Moral."

  • kann mir keiner Helfen, kriege es irgendwie nicht alleine hin....

    lg SubZero ;)
    ==========================================================================

    "Der Computer ist die logische Weiterentwicklung des Menschen: Intelligenz ohne Moral."

  • Hey,

    bin jetzt etwas weiter kann jetzt die erste listview befüllen mit der tabele und dem ersten feld,
    jetzt fehlt mir noch dir wenn ich auf ein item klicke das er mir aus der gleichen tabele die anderen felder füllt?

    So sieht meine tabelle in etwa aus:

    feld11, feld2,feld3,feld4
    wert1,wert2,wert3,wer4,
    werta,wertf,wertb,wertc,
    wert1,wert2,wert3,wer4,
    wertr,wertr,wertf,werg,

    dies habe ich in der listview[0]:
    wert1
    werta
    wert1
    wertr

    Wenn ich jetzt auf ein item in der listview[0] klicke will ich die wertre aus den anderen feldern auslesen.

    also wenn ich werta anklicke will ich z.b. wertb und wertc auslesen wie mache ich das?

    Spoiler anzeigen
    [autoit]

    #include <File.au3>
    #include <GUIConstantsEx.au3>
    #include <GuiListView.au3>
    #include <ListViewConstants.au3>
    #include <WindowsConstants.au3>
    global $dbname = @ScriptDir & "\OPTM CISM_be.mdb" ; Datenbankpfad und Datei-/Datenbankname
    global $tblname = "tbl_CISM_Incident"
    Global $fldname = "Task_Aufgabenname"
    Global $format = "Text(50)"
    Global $data = "Blah Blah Blah" , $aRow
    Global $ListView[9], $_output
    Global $sDir = @ScriptDir & '\csv\'
    Global $aFiles = _FileListToArray($sDir, '*.csv', 1), $sComboFiles
    If Not @error Then
    For $i = 1 To $aFiles[0]
    $sComboFiles &= $aFiles[$i] & '|'
    Next
    $sComboFiles = StringTrimRight($sComboFiles, 1)
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    #Region ### START Koda GUI section ### Form=F:\autoit\entwicklung\CISM\Form1.kxf
    $Form1 = GUICreate("BMC", 949, 555, 197, 277)
    $ListView[0] = GUICtrlCreateListView("1 Short decription", 32, 96, 234, 422)
    GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 80)
    ;$Combo1 = GUICtrlCreateCombo("Combo1", 32, 16, 233, 25)
    $Combo2 = GUICtrlCreateCombo("Liste Auswählen", 32, 72, 233, 25)
    GUICtrlSetData(-1, $sComboFiles)
    ;$Inputun = GUICtrlCreateInput("", 32, 32, 151, 21)
    ;GUICtrlCreateLabel("Caller ", 32, 10, 60, 20)
    ;$Input2 = GUICtrlCreateInput("Input1", 449, 16, 143, 21)
    ;$Input3 = GUICtrlCreateInput("Input1", 601, 16, 143, 21)
    ;$Input4 = GUICtrlCreateInput("Input1", 286, 50, 151, 21)
    ;$Input5 = GUICtrlCreateInput("Input1", 446, 50, 143, 21)
    ;$Input6 = GUICtrlCreateInput("Input1", 598, 50, 143, 21)
    ;$Input7 = GUICtrlCreateInput("Input1", 755, 20, 143, 21)
    ;$Input8 = GUICtrlCreateInput("Input1", 759, 49, 143, 21)
    ;$ListView[1] = GUICtrlCreateListView("2 Detail", 273, 96, 294, 211)
    $ListView[1] = GUICtrlCreateEdit("2 Detail", 273, 96, 294, 211)
    GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 280)
    ;$ListView[2] = GUICtrlCreateListView("3 Way of Solution ", 273, 305, 294, 211)
    $ListView[2] = GUICtrlCreateEdit("3 Way of Solution ", 273, 305, 294, 211)
    GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 280)

    [/autoit] [autoit][/autoit] [autoit]

    $ListView[3] = GUICtrlCreateListView("4 Classification", 572, 95, 146, 54)
    GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 140)

    [/autoit] [autoit][/autoit] [autoit]

    $ListView[4] = GUICtrlCreateListView("5 Compnent Type", 572, 150, 146, 54)

    [/autoit] [autoit][/autoit] [autoit]

    GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 140)
    $ListView[5] = GUICtrlCreateListView("6 Component", 572, 200, 146, 54)
    GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 80)

    [/autoit] [autoit][/autoit] [autoit]

    $ListView[6] = GUICtrlCreateListView("7 Assined To Group", 572, 305, 146, 55)
    GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 80)
    $ListView[7] = GUICtrlCreateListView("8 Submitter Group", 572, 369, 146, 54)
    GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 80)

    [/autoit] [autoit][/autoit] [autoit]

    $ListView[8] = GUICtrlCreateListView("9 Client", 572, 420, 146, 54)
    GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 80)
    ;$Userladen = GUICtrlCreateButton("Userladen", 800, 75, 75, 17, $WS_GROUP)
    ;$Userdel = GUICtrlCreateButton("löschen", 800, 58, 75, 17, $WS_GROUP)
    $Dbread = GUICtrlCreateButton("DB Lesen", 50, 520, 75, 17, $WS_GROUP)
    ;$ListView10 = GUICtrlCreateListView("UserID|im Ad vorhanden", 750, 96, 186, 422)
    ;GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 80)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    GUISetState(@SW_SHOW)

    [/autoit] [autoit][/autoit] [autoit]

    #EndRegion ### END Koda GUI section ###

    [/autoit] [autoit][/autoit] [autoit]

    ;GUICtrlSetData($Inputun, $user2)
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    case $Dbread
    $dbString = _ReadOneFld($tblname, $dbname, $fldname)
    $aRow = StringSplit($dbstring, ';', 3)

    [/autoit] [autoit][/autoit] [autoit]

    For $i = 0 To UBound($aRow) - 1
    $aCol = StringSplit($aRow[$i], ';', 2)

    [/autoit] [autoit][/autoit] [autoit]

    GUICtrlCreateListViewItem($aCol[0], $ListView[0])
    Next
    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _ReadOneFld($_sql, $_dbname, $_field)
    Dim $_output
    $adoCon = ObjCreate ("ADODB.Connection")
    $adoCon.Open ("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $_dbname)
    $adoRs = ObjCreate ("ADODB.Recordset")
    $adoRs.CursorType = 1
    $adoRs.LockType = 3
    $adoRs.Open ($_sql, $adoCon)

    [/autoit] [autoit][/autoit] [autoit]

    With $adoRs
    If .RecordCount Then
    While Not .EOF
    $_output = $_output & .Fields ($_field).Value & ';'

    [/autoit] [autoit][/autoit] [autoit]

    .MoveNext

    [/autoit] [autoit][/autoit] [autoit]

    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    EndWith
    $adoCon.Close

    [/autoit] [autoit][/autoit] [autoit]

    Return $_output
    EndFunc

    [/autoit]

    Kann mir jemand helfen?

    lg SubZero ;)
    ==========================================================================

    "Der Computer ist die logische Weiterentwicklung des Menschen: Intelligenz ohne Moral."