| | |
problem with login page
Please support our C# advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
![]() |
•
•
Join Date: Apr 2006
Posts: 3
Reputation:
Solved Threads: 0
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)
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); } }
Last edited by alc6379; Apr 22nd, 2006 at 7:45 pm.
•
•
Join Date: Jul 2005
Posts: 483
Reputation:
Solved Threads: 19
first, you are setting result to be an int and then comparing it to a string . second, you are trying to use = to compare instead of ==. .
change the second line to
•
•
•
•
int result = (int)radLogin(EmployeeAccessLevel);
•
•
•
•
if (result = "1")
•
•
•
•
if (result = "1")
change the second line to
C# Syntax (Toggle Plain Text)
if (result == 1)
![]() |
Similar Threads
- Updated : Simple ASP.Net Login Page (ASP.NET)
- HELP!! Monitor Shows NO SIGNAL after windows loading / before login page (Windows NT / 2000 / XP)
- Simple ASP.Net Login Page (Using VB.Net) (ASP.NET)
Other Threads in the C# Forum
- Previous Thread: Maximum Array
- Next Thread: Console App, Spawned From Service, File IO
| Thread Tools | Search this Thread |
.net access algorithm array asp.net bitmap box broadcast c# check checkbox client combobox control conversion csharp database datagrid datagridview dataset datetime dbconnection decryption degrees design developer draganddrop drawing encryption enum eventhandlers excel file firefox focus form format forms function gdi+ grantorrevokepermissionthroughc#.net hospitalmanagementsystem image input install interface java libraries list loop marshalbyrefobject math mouseclick movingimage mysql netcfsvcutil.exe numeric operator path photoshop php picturebox pixelinversion platform polynomial post programming properties radians read regex remote remoting richtextbox server sleep socket sql statistics string stringformatting study system.servicemodel table tcpclientchannel text textbox thread time timer update usb usercontrol validation visualstudio webbrowser winforms wpf wpfc# xml






