Login with GUI Matlab
Show older comments
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 Comment
Muhamad Ikhwan
on 28 Feb 2017
Edited: Geoff Hayes
on 1 Mar 2017
Answers (1)
Geoff Hayes
on 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.
Categories
Find more on Workspace Variables and MAT Files in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!