problem with login page

Please support our C# advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
Reply

Join Date: Apr 2006
Posts: 3
Reputation: dave1323 is an unknown quantity at this point 
Solved Threads: 0
dave1323 dave1323 is offline Offline
Newbie Poster

problem with login page

 
0
  #1
Apr 20th, 2006
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.

  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.
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 483
Reputation: campkev is an unknown quantity at this point 
Solved Threads: 19
campkev campkev is offline Offline
Posting Pro in Training

Re: problem with login page

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

change the second line to
  1. if (result == 1)
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 3
Reputation: dave1323 is an unknown quantity at this point 
Solved Threads: 0
dave1323 dave1323 is offline Offline
Newbie Poster

Re: problem with login page

 
0
  #3
Apr 20th, 2006
Thanks for the help, I got that worked out and now when I run it I get Exception errors.
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 483
Reputation: campkev is an unknown quantity at this point 
Solved Threads: 19
campkev campkev is offline Offline
Posting Pro in Training

Re: problem with login page

 
0
  #4
Apr 21st, 2006
post if you need help
Reply With Quote Quick reply to this message  
Join Date: Dec 2003
Posts: 2,414
Reputation: alc6379 has a spectacular aura about alc6379 has a spectacular aura about alc6379 has a spectacular aura about 
Solved Threads: 123
Team Colleague
alc6379's Avatar
alc6379 alc6379 is offline Offline
Cookie... That's it

Re: problem with login page

 
0
  #5
Apr 22nd, 2006
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?
Alex Cavnar, aka alc6379
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC