Please help me out. I need Silverlight 5 code as soon as possible. My requirements are:
I have a table as follows:
| ID(PK), int | Username | Password | Role |
| 1 | A | abcd | IT |
| 2 | B | efgh | User |
:
I have a Silverlight Application and I have added Silverlight-Enabled WCF Service and LINQ-TO-SQL Class.
I want that:s
When the user enters the username and password in the textboxes, the system should check whether the user is present in the database or not.
If yes, the system should return the role of the user.
Eg-if the username and password entered are A and abcd respectively, I want IT on a textbox.
Please do help me out as I am not able to use the Single() method of LINQ-TO-SQL Class.
Thanks in advance.....
Vikrant MorePosted Oct 9, 2012, 2:30 AM
[OperationContract]
public Boolean Login(string UserName,string Password,string role)
{
List
Login l1;
var test = from a in db.Login1s where a.UserName==UserName.ToString() && a.Password==Password.ToString() && a.Role == role.ToString() select a;
foreach (var t in test)
{
l1 = new Login()
{
id = t.id,
UserName = t.UserName,
Password = t.Password
};
l.Add(l1);
}
if (l.Count != 0)
{
return true;
}
else
{
return false;
}
}
try using this.
if it returns true then you have logged in successfully.