MATLAB: Update row in database

Database Toolboxdatebaseupdate

Hi ..
In database I have Id and its type is 'int', also I have Name and its type is varchar
When I tried to update the Id it was work:
Id = str2num(get(handles.ID,'String'));
y = exec(conn,'select Id from admin_info')
y = fetch(y);
y1=(y.Data)
colnames3={'Id'};
whereclause3 = ['WHERE ID= ' num2str(y1{1})]
update(conn,'admin_info', colnames3, Id, whereclause3);
But the update for the name it doesn't work !
name = get(handles.name, 'String')
x = exec(conn,'select name from admin_info');
x = fetch(x);
x1 = x.Data
n = x1{1}
colnames2={'name'};
whereclause2 = ['WHERE name = ' n]
update(conn,'admin_info', colnames2, name, whereclause2);

Best Answer

Reading the documentation for update, it indicates that the new data (input number 4) cannot be a character array. The ID worked because it can handle numeric matrix. To update a char/string entry, use a cellstr input.
update(conn,'admin_info', colnames2, cellstr(name), whereclause2);