DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   C# (http://www.daniweb.com/forums/forum61.html)
-   -   problem with login page (http://www.daniweb.com/forums/thread43733.html)

dave1323 Apr 20th, 2006 1:51 pm
problem with login page
 
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.

private void Submitbutton_Click(object sender, EventArgs e)
        {
            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");
            OleDbCommand cmdLogin = new OleDbCommand("select EmployeeAccessLevel from OSicher where (EmployeeName = 'warehouse' AND EmployeePassword = 'house') OR (EmployeeName = 'inventory' AND EmployeePassword = 'staff')", objconn);
            try
            {
                objconn.Open();
                OleDbDataReader radLogin = cmdLogin.ExecuteReader();
                while (radLogin.Read())
                {
                    int result = (int)radLogin(EmployeeAccessLevel);
                    if (result = "1")
                    {
                        frmManagerHome frm = new frmManagerHome();
                        frm.Show();
                    }
                }
                radLogin.Close();
                objconn.Close();
            }
            catch(OleDbException er)
            {
                Console.WriteLine("Error: {0}", er.Errors[0].Message);
            }
        }

campkev Apr 20th, 2006 6:42 pm
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
if (result == 1)

dave1323 Apr 20th, 2006 11:50 pm
Re: problem with login page
 
Thanks for the help, I got that worked out and now when I run it I get Exception errors.

campkev Apr 21st, 2006 5:42 pm
Re: problem with login page
 
post if you need help

alc6379 Apr 22nd, 2006 8:02 pm
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?


All times are GMT -4. The time now is 5:14 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC