Login with GUI Matlab
Afficher commentaires plus anciens
Hi, i alrdy success connecting my matlab with ms Access.. The problem is i doesnt know how to query. I have 2 edit text which to ask user to input username n password, after click login the system will refer to my databse. If wrong username n password the messagebox will popout and say fail.. any1 good at query the database can share
1 commentaire
Muhamad Ikhwan
le 28 Fév 2017
Modifié(e) : Geoff Hayes
le 1 Mar 2017
Réponses (1)
Geoff Hayes
le 1 Mar 2017
Muhammad - why are you comparing a with b
l=strcmp(a,b);
if l==1
% etc.
end
Aren't these the username and password and so should be different?
If curs.Data is a cell array (?) of usernames and passwords from the database, then I suspect that you would need to do something like
usernamePwdData = curs.Data;
guiUsername = get(handles.edit1,'String'); % I'm guessing edit1 is for username
guiPassword = get(handles.edit2,'String'); % I'm guessing edit2 is for password
validUser = false;
for k=1:length(usernamePwdData)
username = usernamePwdData{k,1};
password = usernamePwdData{k,2};
if strcmp(username,guiUsername) && strcmp(password,guiPassword)
validUser = true;
break;
end
end
if validUser
AdminManagement()
UserManagement()
else
msgbox('wrong pwd');
end
I'm also assuming that curs.Data is a cell array of N rows and 2 columns. If different, you would need to adjust the above code.
Catégories
En savoir plus sur Workspace Variables and MAT Files 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!