SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 485 | Next

Scott Klein

"Professional LINQ"

Show("Invalid username or password.", this.Text);
}
}
else
{
MessageBox.Show("Enter a valid username and password.", this.Text);
}
Below the Click() event of the OK button, add the following code. This code is what the Click() event
will call to authenticate the user entered on the login form.
private bool Authenticate(string un, string pwd)
{
bool isValid = false;
FabrikamDataContext context = new FabrikamDataContext("user id=username;
password=password");
IEnumerable result = context.GetActiveEmployees();
foreach (GetActiveEmployeesResult emp in result)
{
if (emp.LoginName.ToLower() == un.ToLower() && emp.Password == pwd)
{
isValid = true;
break;
}
}
return isValid;
}
Before proceeding, compile the application to make sure that everything compiles OK. If there are no
errors, press F5 to run the application. First, the login form will appear. For credentials, enter RussellK
for the username and password for the password.
The Authenticate routine uses LINQ to SQL to call a mapped stored procedure to return all the existing
employees.


Pages:
473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6