accessing data from handles structure from a call back fuction
    5 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
 I am new in matlab GUI. The code I have written is as follows:
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%# JDBC connector path
    %javaaddpath('C:\DB\mysql-connector-java-5.1.17-bin.jar')
    %# connection parameteres
    host = 'localhost'; %MySQL hostname
    user = 'root'; %MySQL username
    password = '';%MySQL password
    dbName = 'signature'; %MySQL database name
    %# JDBC parameters
    jdbcString = sprintf('jdbc:mysql://%s/%s', host, dbName);
    jdbcDriver = 'com.mysql.jdbc.Driver';
 conn = database(dbName, user , password, jdbcDriver, jdbcString); 
 if isconnection(conn)
    list=get(handles.popupmenu1,'String');
val=get(handles.popupmenu1,'Value');
m=list{val};
    qry2 = sprintf('SELECT sign FROM signature where name="%s"',m);
    display(qry2);
    rs2=fetch(exec(conn, qry2));
     alldata2=get(rs2,'Data');
    display(alldata2);
    qry1 = sprintf('SELECT sign FROM sig_master where name="%s"',m);
    display(qry1);
    rs1=fetch(exec(conn, qry1));
     alldata1=get(rs1,'Data');
    display(alldata1);
   % delete(handles.figure1)
 end
 handles.in = alldata2;
 handles.master = alldata1;
I want to take data from handles.in and handles.master and assign them to two variables. This process is to be done when push button2 is pressed. Could you pls help me to do this.
function pushbutton2_Callback(hObject, eventdata, handles)
0 Commenti
Risposte (1)
  Adam
      
      
 il 7 Mar 2015
        You need to add
guidata( hObject, handles );
at the end of your pushbutton1_Callback.
Then in pushbutton2_Callback you can access your data again as
handles.in
handles.master
and do whatever you want with them in the scope of pushbutton2's callback.
0 Commenti
Vedere anche
Categorie
				Scopri di più su Database Toolbox in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

