In the above code, it is executing with out showing errors but the record is not update in the database.
function Reg_pwd_gen(uname1)
mm = floor(1000+(rand()*8999));
conn = database('mani','root','MARUTHI');
tablename='user2';
colnames = {'pwd'};
data={'mm'};
whereclause={'WHERE uname = ''{uname1} '''};
update(conn,tablename,colnames,data,whereclause);
commit(conn);
close(conn);
Reg_pwd = uicontrol('Style','text','FontSize',10,'FontWeight','bold',...
'Position',[10 500 200 50],...
'String','Please Remember the Password for Authention. ')
pwd1= uicontrol('Style','edit','FontSize',12,'FontWeight','bold',...
'Position',[550 500 100 60],...
'String',mm)
% code
end
Please help me for my project and also send me the reply as early as posssible.

7 commentaires

Guillaume
Guillaume le 17 Août 2017
What does a SELECT statement with the same whereclause return?
Maruthi Maruthi
Maruthi Maruthi le 17 Août 2017
I need to update mm value in the database.
Guillaume
Guillaume le 17 Août 2017
Modifié(e) : Guillaume le 17 Août 2017
I am aware. We don't yet know if the update does not happen because there is nothing to update (i.e. WHERE returns nothing) or something else. Until you've confirmed that a SELECT with the same where returns some records, we can only assume that you're not getting updates because your where clause is wrong.
Maruthi Maruthi
Maruthi Maruthi le 18 Août 2017
I'm going to check username i.e uname1 variable value in the matlab and the uname value in the table is match then pwd value update in the table.
Maruthi Maruthi
Maruthi Maruthi le 18 Août 2017
Sir, please help me where I was wronng in the where clause.
Guillaume
Guillaume le 18 Août 2017
Modifié(e) : Guillaume le 18 Août 2017
I did not say you were wrong. I said we don't know. So, for the 3rd time, please run a SELECT * query with the exact same WHERE clause. If it returns records, then we know you're not wrong and we can start looking for other issues. If it returns nothing, then we can start seeing what is wrong with your WHERE.
Maruthi Maruthi
Maruthi Maruthi le 21 Août 2017
thank you sir. can you please provide the syntax of update command if the data store in some other variable and at the same time where clause value also points to the value in the variable. i.e., data=mm; %uname=uname1; uname1 has some data. update (conn,'user2','pwd',data, where uname=uname1); is this correct?

Connectez-vous pour commenter.

Réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by