How matlab display data from database in gui edit box

조회 수: 1 (최근 30일)
Gytis Raudonius
Gytis Raudonius 2016년 10월 2일
댓글: Geoff Hayes 2019년 4월 29일
Hi everyone, i programing license plate recognition programs, and appeared problem. So after few examples i figure out my code.
function pushbutton1_Callback(hObject, eventdata, handles)
conn = database('baze', 'root', 'root', 'Vendor', 'MYSQL', 'Server', 'localhost', 'PortNumber', 3306);
setdbprefs('datareturnformat','structure');
a = get(handles.edit8,'String');
if iscell(a) && numel(a) == 1
a = a{1};
end
if ~ischar(a) || isempty(a);
error('A valid string must be supplied!');
end
sqlquery = ['select vardas, pavarde, laipsnis, pareigos, telefonas, marke, numeris, tarnyba from info '...
'where numeris = ' '''' a ''''];
curs = exec(conn, sqlquery);
curs = fetch(curs);
curs.data
close(curs)
close(conn)
All this i got in Matlab command window, but if i have gui aplication and i want retrive value in gui wich have edit text box. Example: after i input car plate number - got 'vardas' in edit1 and 'pavarde' in edit2. Thanks in advance for the answers.
  댓글 수: 2
akshatha nayak
akshatha nayak 2019년 4월 29일
How to display the database rows in GUI Or database multiple rows in GUI
Geoff Hayes
Geoff Hayes 2019년 4월 29일
akshatha - I see that you have a question posted at https://www.mathworks.com/matlabcentral/answers/459147-how-to-display-the-database-in-gui-or-database-multiple-rows-in-gui. Please further the conversation there.

댓글을 달려면 로그인하십시오.

채택된 답변

Geoff Hayes
Geoff Hayes 2016년 10월 2일
Gytis - if you want to retrieve the text from your edit1 and edit2 controls, then in the above pushbutton callback you would use the handles structure to get the values for these controls:
edit1Text = get(handles.edit1,'String');
edit2Text = get(handles.edit2,'String');
You can then use the above two local variables however you wish. Is this the solution that you are looking for?
  댓글 수: 8
Gytis Raudonius
Gytis Raudonius 2016년 10월 31일
no it's not working error like Error using subsref Cell contents reference from a non-cell array object.
Gytis Raudonius
Gytis Raudonius 2016년 11월 1일
solve added code
curs = exec(conn, sqlquery);
setdbprefs('DataReturnFormat','cellarray');
curs = fetch(curs);
vardas = curs.data(1,1);

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Database Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by