如何使用MySQL数据库中的值填充matlab GUI编辑文本?

时间:2015-05-11 10:43:10

标签: mysql matlab

我在matlab数据库工具箱中创建了一个包含10列的表。如何检索值并在matlab GUI中显示它们?当我使用下面的代码时,我得到未定义函数'fetch'用于'double'类型错误的输入参数。谁能告诉我我的代码有什么问题?

f = getappdata(0,'fvalue');

%Set preferences with setdbprefs.
setdbprefs('DataReturnFormat', 'cellarray');
setdbprefs('NullStringRead', 'null');


%Make connection to database. 
conn = database('marine_invertebrates', '', '');

%Read data from database.
curs = fetch(conn, sprintf(['SELECT	 description.commonName'...
    ' ,	description.scientificName'...
    ' ,	description.kingdom'...
    ' ,	description.phylum'...
    ' ,	description.subphylum'...
    ' ,	description.class'...
    ' ,	description.order'...
    ' ,	description.family'...
    ' ,	description.genus'...
    ' ,	description.species'...
    ' FROM 	marine_cbir.description WHERE description.imageID = "%s"'], num2str(f)));

curs = fetch(curs);
close(curs);

%Assign data to output variable
results = curs.Data;

commonName = set(handles.edit11,'String'); 
display (commonName);
scientificName = set(handles.edit1,'String');
display (scientificName);
kingdom = set(handles.edit2,'String');
display (kingdom);
phylum = set(handles.edit3,'String'); 
display (phylum);
subphylum = set(handles.edit4,'String');
display (subphylum);
class = set(handles.edit5,'String');
display (class);
order = set(handles.edit6,'String');
display (order);
family = set(handles.edit7,'String');
display (family );
genus = set(handles.edit8,'String');
display (genus);
species = set(handles.edit9,'String');
display (species );

    

0 个答案:

没有答案