Jump to content

SQL Array into GUI drop down box


Bendo
 Share

Recommended Posts

Hi all,

I've been searching and there are examples but I can't seem to get this...

I can get information out of a MS SQL db and get it into an array.

Next I want to be able to select one of the eight digit results via a drop down box or even a list... whatever... (eventually I'll have thousands of these numbers) and then do something with the selected result.

I can't seem to get the display working...

Below code works (but how do I do a screenshot???)

#include <GUIConstants.au3>
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <_sql.au3>
#include <array.au3>
#include <PopG_GuiCtrl.au3>
 
 
;This does the SQL login stuff...
 
Opt ("trayIconDebug",1)
     _SQL_RegisterErrorHandler()
    $oADODB = _SQL_Startup();
    If $oADODB = $SQL_ERROR then Msgbox(0 + 16 +262144,"Error",_SQL_GetErrMsg())
    If _sql_Connect(-1,"HT8\SQLEXPRESS","master","sa","password") = $SQL_ERROR then
        Msgbox(0 + 16 +262144,"Error",_SQL_GetErrMsg())
        _SQL_Close()
        Exit
    EndIf
 
 
;This puts results into array...
 
Local $aItems,$iRows,$icolumns
$iRval = _SQL_GetTable2d(-1,"select loginname from master..syslogins WHERE isnumeric(loginname) = 1 and LEN(loginname)=8 order by loginname;",$aItems,$iRows,$icolumns)
 
 
 
;This gets the results into a gui...
 
info Local $hListView
    ; Create GUI
    GUICreate("Changer", 400, 200)
    $hListView = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState()
    ; Add columns
    _GUICtrlListView_AddColumn($hListView, "Login Name", 100)
    _GUICtrlListView_AddArray($hListView, $aItems)
    ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()

1. I want to get rid of the word "loginname" from within the results but have all the numbers, but not get rid of "Login Name" from the heading.

2. The GUI should be a dropdown and selectable so I can the get on with processing the next step.

All I seem able to do is break it or only display array column or row numbers like 0 or 1 but not the actual data.

Any pointers in the right direction appreciated.

Edited by Bendo
Link to comment
Share on other sites

Ok, to load an array into a dropdown box, you could have something like this:

#include <Array.au3>
Global $array[5] = [1,2,3,4,5]
GUICreate("", 250, 100)
GUICtrlCreateCombo("", 25, 40)
GUICtrlSetData(-1, _ArrayToString($array), $array[0])
GUISetState()
While 1
    $msg = GUIGetMsg()
    If $msg = -3 Then Exit
WEnd

There, I just have a GUI which loads 1 through to 5 into the dropdown.

Is this what you are looking for?

Link to comment
Share on other sites

  • 2 weeks later...

Hey thanks Mikeman27294,

You're a champ and definitely what I was trying to do.

I have SQL output going into the array but couldn't figure how to get the dropdown to work.

You are definitely worth more money... although you're not getting it from me 8~)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...