944,155 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 1764
  • C# RSS
Apr 20th, 2006
0

problem with login page

Expand Post »
Hello I am new to csharp and am having some trouble with a projec that I am working on. I have a database(access) and am using a window form for a login page. The login is supposed to check a couple conditions and then return an int from the database which says which accesslevel that login has. Something is wrong with my code I am having trouble with making the return value an int and am just lost. Any help would be appreciated my code is below.

C# Syntax (Toggle Plain Text)
  1. private void Submitbutton_Click(object sender, EventArgs e)
  2. {
  3. OleDbConnection objconn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c://documents and settings/davidsinclair/My Documents/Visual Studio 2005/Projects/PINS/PINS/pinsdb.mdb");
  4. OleDbCommand cmdLogin = new OleDbCommand("select EmployeeAccessLevel from OSicher where (EmployeeName = 'warehouse' AND EmployeePassword = 'house') OR (EmployeeName = 'inventory' AND EmployeePassword = 'staff')", objconn);
  5. try
  6. {
  7. objconn.Open();
  8. OleDbDataReader radLogin = cmdLogin.ExecuteReader();
  9. while (radLogin.Read())
  10. {
  11. int result = (int)radLogin(EmployeeAccessLevel);
  12. if (result = "1")
  13. {
  14. frmManagerHome frm = new frmManagerHome();
  15. frm.Show();
  16. }
  17. }
  18. radLogin.Close();
  19. objconn.Close();
  20. }
  21. catch(OleDbException er)
  22. {
  23. Console.WriteLine("Error: {0}", er.Errors[0].Message);
  24. }
  25. }
Last edited by alc6379; Apr 22nd, 2006 at 7:45 pm.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
dave1323 is offline Offline
3 posts
since Apr 2006
Apr 20th, 2006
0

Re: problem with login page

first, you are setting result to be an int
Quote ...
int result = (int)radLogin(EmployeeAccessLevel);
and then comparing it to a string
Quote ...
if (result = "1")
. second, you are trying to use = to compare instead of ==.
Quote ...
if (result = "1")
.

change the second line to
C# Syntax (Toggle Plain Text)
  1. if (result == 1)
Reputation Points: 14
Solved Threads: 19
Posting Pro in Training
campkev is offline Offline
484 posts
since Jul 2005
Apr 20th, 2006
0

Re: problem with login page

Thanks for the help, I got that worked out and now when I run it I get Exception errors.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
dave1323 is offline Offline
3 posts
since Apr 2006
Apr 21st, 2006
0

Re: problem with login page

post if you need help
Reputation Points: 14
Solved Threads: 19
Posting Pro in Training
campkev is offline Offline
484 posts
since Jul 2005
Apr 22nd, 2006
0

Re: problem with login page

Quote originally posted by dave1323 ...
Thanks for the help, I got that worked out and now when I run it I get Exception errors.
What exception errors are you getting, exactly?
Team Colleague
Reputation Points: 186
Solved Threads: 147
Cookie... That's it
alc6379 is offline Offline
2,519 posts
since Dec 2003

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: Maximum Array
Next Thread in C# Forum Timeline: Console App, Spawned From Service, File IO





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC