Update database in gui but dont get updated data.
Afficher commentaires plus anciens
HI, i try to update database in gui, but my code dont working and dont get error also database not updated please help me. there is table:

code
function pushbutton2_Callback(hObject, eventdata, handles)
colnames = {'vardas','pavarde','laipsnis','pareigos','telefonas','marke','numeris','tarnyba'};
conn = database('baze', 'root', 'root', 'Vendor', 'MYSQL', 'Server', 'localhost', 'PortNumber', 3306);
set(conn, 'AutoCommit', 'on');
get(conn, 'AutoCommit');
update(conn, 'info', colnames,{handles.edit1,handles.edit2,handles.edit3,handles.edit4,handles.edit5,handles.edit6,handles.edit7,handles.edit8},['where id = ' sprintf('%f',handles.text9)])
close(conn);
Réponses (1)
Geoff Hayes
le 3 Juin 2017
Gytis - in your command
update(conn, 'info', colnames, ...
{handles.edit1,handles.edit2,handles.edit3,handles.edit4,handles.edit5,handles.edit6,handles.edit7,handles.edit8},...
['where id = ' sprintf('%f',handles.text9)])
you are populating the cell array of values with the handles of the edit controls rather than the strings that have been entered in to each edit control. Rather than using the handle, you will need to extract the string first
vardasValue = get(handles.edit1,'String');
(though this will depend upon which version of MATLAB that you are using).
4 commentaires
Gytis Raudonius
le 3 Juin 2017
Geoff Hayes
le 3 Juin 2017
Put a breakpoint in the code and then check to see what the command is that you are submitting to the database. Also, what is your where clause? Your code (unless changed) is
['where id = ' sprintf('%f',handles.text9)]
Again, you will need to do
id = get(handles.text9, 'String');
and
['where id = ' id ]
Gytis Raudonius
le 3 Juin 2017
Geoff Hayes
le 3 Juin 2017
Gytis - you will have to post all of your code so that I can see what you've written. From the error, it sounds like you have two where clauses...
Catégories
En savoir plus sur Database Toolbox dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!