nevodj Posted September 24, 2014 Share Posted September 24, 2014 Hello, In my GUI I have a combobox that is populated from an SQL query, like select id, name from persons. In the combobox I want to display the name, but when the person's name is selected from the combobox, I want to retrieve the id relevant to the selected person, so I can use it later in the script. GUICtrlRead will return the person name, but that will not work as it may not be unique. How can I read the ID of the selected person? It's hard to explain, apologies if this is not clear. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 24, 2014 Moderators Share Posted September 24, 2014 nevodj,If the names may not be unique in the combo, how do you know you have selected the correct one? Why not display both name and ID in the combo? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
nevodj Posted September 24, 2014 Author Share Posted September 24, 2014 I knew someone would ask that.... ID is a database primary key so means nothing to the user. To deal with duplicates in the list, I may display name and city or something like that. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 24, 2014 Moderators Share Posted September 24, 2014 nevodj,How is the data returned from the database? I imagine it is an array from which you extract elements to populate the combo. If so then just search the array for matches to the name (and whatever else you decide to add to make them unique) and read off the associated ID. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
nevodj Posted September 24, 2014 Author Share Posted September 24, 2014 Hello, I am using the _Sql_GetTableAsString function to get the data as a string, then stringreplace to replace the carriage returns in the string with pipes, then using guictrlsetdata to push that into the combobox. I am not sure how I'd load multiple fields. Any help is appreciated. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 24, 2014 Moderators Share Posted September 24, 2014 nevodj,I am not a database expert, and what little I do know is based on SQLite and its associated UDF whereas I assume you are using this SQL UDF. It sounds to me from your post that you are pulling the names as a single query. With that UDF can you not get both the name and the identifier you will have to use (city?) at the same time? Then you will be able to add both to the combo and re-query the database to extract the ID once a selection is made. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
nevodj Posted September 25, 2014 Author Share Posted September 25, 2014 Thanks M23. I will look into this. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now