count instances of item in excel using ado sql with autoit

can someone help me
i have the following data


items      assets
      
Monitor      4234
Keyboard      4235
Mouse      4236
Monitor      4237
Monitor      4238
monitor      4239
test       5333
test2      5534



i'm wanting to display it like this in a list control

Keyboard    1
Monitor      4
Mouse       1
test             1
test2           1


instead i'm getting

1
3
keyboard
mouse
monitor
test
test2


here is my code
func excel ()
Const $adOpenStatic = 3
Const $adLockOptimistic = 3
Const $adCmdText = 0x0001 
Global $s_Filename=FileGetShortName("database.xls") 
Global $s_Tablename = "[Sheet1$]" 

; Initialize COM error handler 
global $oMyError = ObjEvent("AutoIt.Error","MyErrFunc")

; Source XLS data
$objConnection = ObjCreate("ADODB.Connection")
$objRecordSet = ObjCreate("ADODB.Recordset")
$objConnection.Open ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&$s_Filename&";Extended Properties=""Excel 8.0;HDR=Yes;"";")
$objRecordSet.Open ("Select [Items]" &',' & "count(*) FROM "& $s_Tablename & " GROUP BY [Items]", $objConnection, $adOpenStatic, $adLockOptimistic, $adCmdText)

Do
    For $x In $objRecordSet.Fields
       ;MsgBox (0, "", "Column: " & @CRLF & $x.name & @CRLF & "Value: " & $x.value)
	   guictrlsetdata($List2, $x.Value )
    Next
    
    $objRecordSet.MoveNext
Until $objRecordSet.EOF

$objConnection.Close
$objConnection = ""
$objRecordSet = ""

EndFunc

Func MyErrFunc()
  $HexNumber=hex($oMyError.number,8)
  Msgbox(0,"COM Test","We intercepted a COM Error !"       & @CRLF  & @CRLF & _
             "err.description is: "    & @TAB & $oMyError.description    & @CRLF & _
             "err.windescription:"     & @TAB & $oMyError.windescription & @CRLF & _
             "err.number is: "         & @TAB & $HexNumber              & @CRLF & _
             "err.lastdllerror is: "   & @TAB & $oMyError.lastdllerror   & @CRLF & _
             "err.scriptline is: "     & @TAB & $oMyError.scriptline     & @CRLF & _
             "err.source is: "         & @TAB & $oMyError.source         & @CRLF & _
             "err.helpfile is: "       & @TAB & $oMyError.helpfile       & @CRLF & _
             "err.helpcontext is: "    & @TAB & $oMyError.helpcontext _
            )
  SetError(1)  ; to check for after this function returns
Endfunc

Open in new window

bbimisAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

FamousMortimerCommented:
Hi,

Does it work if you change the recordset open to this?

$objRecordSet.Open ("Select [Items], count([assets]) FROM "& $s_Tablename & " GROUP BY [Items]", $objConnection, $adOpenStatic, $adLockOptimistic, $adCmdText)

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bbimisAuthor Commented:
I figured it out I was looping the fields and not just the records
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.