Login with GUI Matlab
显示 更早的评论
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 个评论
Muhamad Ikhwan
2017-2-28
编辑:Geoff Hayes
2017-3-1
回答(1 个)
Geoff Hayes
2017-3-1
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.
类别
在 帮助中心 和 File Exchange 中查找有关 Workspace Variables and MAT Files 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!