Hello Guys, I'm new in Autoit and have no idea of what i'm doing.
I'm traying to populate a listview with a SQL command, to get data in a spreadsheet in Access DataBase. So, here is my poor code.
I can get 1 Item, but when a put the if's my code don't run. I think its a logic problem, like I said before, I have no ideia WTH I'm doing.
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>
Example()
Func Example()
Local $dbname = FileOpenDialog("Choose Access Database", @ScriptDir, "Access files (*.accdb)", 1)
$adoCon = ObjCreate("ADODB.Connection")
$adoCon.Open("Driver={Microsoft Access Driver (*.mdb, *.accdb)}; DBQ=" & $dbname & ";Uid=;Pwd=;")
$adoRs = ObjCreate("ADODB.Recordset")
$adoRs.CursorType = 1
$adoRs.LockType = 3
GUICreate("listview items", 550, 250, 100, 200, -1, $WS_EX_ACCEPTFILES)
Local $idListview = GUICtrlCreateListView("Codigo |Nome |Valor ", 10, 10, 520, 150) ;,$LVS_SORTDESCENDING
For $i=0 to 10
$query = "SELECT * FROM Produtos1 WHERE codigo < 10"
$adoRs.Open ($query, $adoCon)
$codigo = $adoRs.Fields("codigo").value
$nome = $adoRs.Fields("Nome").value
$valor = $adoRs.Fields("valor").value
$adoCon.Close
Local $idItem1 = GUICtrlCreateListViewItem($codigo & "|" & $nome & "|" & $valor , $idListview)
GUISetState(@SW_SHOW)
Next
; Loop until the user exits.
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
;~ Case $idButton
;~ MsgBox($MB_SYSTEMMODAL, "listview item", GUICtrlRead(GUICtrlRead($idListview)), 2)
Case $idListview
MsgBox($MB_SYSTEMMODAL, "listview", "clicked=" & GUICtrlGetState($idListview), 2)
EndSwitch
WEnd
EndFunc ;==>Example
I have uploaded my .accdb file too.
Guys, in this case, what I need to do!?
bd-teste.accdb