How to make a GUI that outputs data from SQLdatabase corresponding to the input?

1 vue (au cours des 30 derniers jours)
So I'm pretty new at this, so I've been having some trouble with this project. Basically, I am given an excel sheet of data, which I imported into sql. Now in my matlab gui, I wanted to have a list box of unique ID numbers (9732 to 9806 to be exact); these numbers correspond to a specific line of data. What I wanted was the user can choose a number from the list and the gui would spit out the data for that exact number in static text boxes. Any recommendations to go about this?

Réponse acceptée

Geoff Hayes
Geoff Hayes le 20 Jan 2017
maybellene - if you are using GUIDE (and I suppose even if you aren't!) you would need to use the listbox callback function which fires whenever the user selects something from the list box. For a GUIDE-created GUI, you would do
function listbox1_Callback(hObject, eventdata, handles)
listElements = get(hObject,'String'); % cell array of items
selectIdx = get(hObject,'Value'); % the index of the item selected by user
element = listElements{selectIdx}; % the element (id or whatever)
You would then convert element to the appropriate data type (probably an integer) and then build your SQL statement to query your database for the item whose ID is element. With the response, you would then update your static text fields using the handles structure (which has a handle to each text box).

Plus de réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by