| | |
multiple user authentication..
Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Jan 2008
Posts: 25
Reputation:
Solved Threads: 0
Hi there,i have joined newly to this site....I am a learner as off now.i am developing a windows application using c#.net..
I have two types of users Admin and Normal users.
I am having one login screen.i want the application to identify the two types of users when they enter their username and password.
i saw the post of using session in asp.net,but how to initialize the session and how to use it and how to identify the two types of users who are in the same table.
The user login details for both admin and normal users are in a single table called account..
Table account
uId Pwd
(for admin) admin admin
(for normal user) counter counter
Help me out dude......
Thanks in advance......
I have two types of users Admin and Normal users.
I am having one login screen.i want the application to identify the two types of users when they enter their username and password.
i saw the post of using session in asp.net,but how to initialize the session and how to use it and how to identify the two types of users who are in the same table.
The user login details for both admin and normal users are in a single table called account..
Table account
uId Pwd
(for admin) admin admin
(for normal user) counter counter
Help me out dude......
Thanks in advance......
In UserClass define UserType enumerator and assign it a value (came from database userTable) indicates it as an admin or user
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
No flag needed, he must put a foreign key in UserTable to identity UserType (Admin or User)
About session, I didn't notice
About session, I didn't notice
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
Okay i thought.....he/she uses the single table....actually he/she writes...."The user login details for both admin and normal users are in a single table called account.."
if the user Type (admin or normal user) details are in the other table....then u must have to use the foreign key.........
thanx Ramy
if the user Type (admin or normal user) details are in the other table....then u must have to use the foreign key.........
thanx Ramy
•
•
Join Date: Jan 2008
Posts: 25
Reputation:
Solved Threads: 0
Hey fellows,
Thanks for the replies dudes...
Like ramy said the use of foreign key is necessary if i have two tables.but i am having a single table called account...
I will explain it clearly.
I have a login form where both admin and normal users enter.
The login details are in a single table called account which has the user name and password of both type of users..
If admin logs in he should be taken to a different form and if normal user logs in he should be taken to a different form..
I should do this by taking the user name..I should identify the user(super or normal) by the user name he enters in textbox1...see the code
[code] if ((textBox1.Text == "") || (textBox2.Text == ""))
{
label3.Visible = true;
label3.Text = "User name or Password is left blank";
return;
}
Con = new SqlConnection("Server=PSTLCORPSERV;database='booking';user id=sa;password=sqlserver12#");
Con.Open();
Cmd = new SqlCommand("select * from account where uname=@name and password= @pwd", Con);
Cmd.Parameters.Add("@name", SqlDbType.VarChar);
Cmd.Parameters.Add("@pwd", SqlDbType.VarChar);
Cmd.Parameters[0].Value = textBox1.Text;
Cmd.Parameters[1].Value = textBox2.Text;
Data = Cmd.ExecuteReader();
if (Data.Read() == true)
{
label3.Text = "valid user";
Admin_Page ad = new Admin_Page(textBox1.Text);
ad.Show();
this.Hide();[\code]
Thanks for the replies dudes...
Like ramy said the use of foreign key is necessary if i have two tables.but i am having a single table called account...
I will explain it clearly.
I have a login form where both admin and normal users enter.
The login details are in a single table called account which has the user name and password of both type of users..
If admin logs in he should be taken to a different form and if normal user logs in he should be taken to a different form..
I should do this by taking the user name..I should identify the user(super or normal) by the user name he enters in textbox1...see the code
[code] if ((textBox1.Text == "") || (textBox2.Text == ""))
{
label3.Visible = true;
label3.Text = "User name or Password is left blank";
return;
}
Con = new SqlConnection("Server=PSTLCORPSERV;database='booking';user id=sa;password=sqlserver12#");
Con.Open();
Cmd = new SqlCommand("select * from account where uname=@name and password= @pwd", Con);
Cmd.Parameters.Add("@name", SqlDbType.VarChar);
Cmd.Parameters.Add("@pwd", SqlDbType.VarChar);
Cmd.Parameters[0].Value = textBox1.Text;
Cmd.Parameters[1].Value = textBox2.Text;
Data = Cmd.ExecuteReader();
if (Data.Read() == true)
{
label3.Text = "valid user";
Admin_Page ad = new Admin_Page(textBox1.Text);
ad.Show();
this.Hide();[\code]
add new column in your user table to identify the user type, sure you can't do that using just username and password!!!
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
•
•
Join Date: Jan 2008
Posts: 25
Reputation:
Solved Threads: 0
ok i have added a new column in my user table called utype..In my code i have written
How to grab that value in my code...
But it is not working.It is saying that no overload for method read takes 1 arguments..Where to use this logic and what code should i use dudes...
I am going to enter only user name and password in my login page...It should fetch the value from the database based on the username i give in textbox1......
Is this possible fellows.....
Cmd = new SqlCommand("select * from account where uname=@name and password= @pwd and utype =@type", Con);
Cmd.Parameters.Add("@name", SqlDbType.VarChar);
Cmd.Parameters.Add("@pwd", SqlDbType.VarChar);
Cmd.Parameters.Add("@type", SqlDbType.Int); Cmd.Parameters[0].Value = textBox1.Text;
Cmd.Parameters[1].Value = textBox2.Text;
Data = Cmd.ExecuteReader();
if (Data.Read(0) == true)
{
label3.Text = "valid user";
Admin_Page ad = new Admin_Page(textBox1.Text);
ad.Show();
this.Hide();
}
else if (Data.Read(1)==true) {
Seat_Book sb=new Seat_Book();
sb.Show();
this.Hide();
}But it is not working.It is saying that no overload for method read takes 1 arguments..Where to use this logic and what code should i use dudes...
I am going to enter only user name and password in my login page...It should fetch the value from the database based on the username i give in textbox1......
Is this possible fellows.....
Last edited by bharathi_n_r; Jan 7th, 2008 at 1:24 am.
Why this "and utype =@type" in your select statement??!!!! you want to filter selected user by utype ??! as you don't know his\her type at all
what you need to modify is to add new column in user table and select userID and uType using user name AND password!
Assign user object ID property with id returned from DB and also uType property (enum).
before calling a method check uType to authorize the current user.
P.S: DataReader.Read() doesn't take any arguments!! to loop for many records (and you don't need that in your case) use while loop
like
what you need to modify is to add new column in user table and select userID and uType using user name AND password!
Assign user object ID property with id returned from DB and also uType property (enum).
before calling a method check uType to authorize the current user.
P.S: DataReader.Read() doesn't take any arguments!! to loop for many records (and you don't need that in your case) use while loop
like
C# Syntax (Toggle Plain Text)
while(reader.Read()) { ///some sort of code goes here! }
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
![]() |
Similar Threads
- User Authentication multiple user types (PHP)
- I need help (Viruses, Spyware and other Nasties)
- Homepage has been changed to about:blank (Viruses, Spyware and other Nasties)
- I can't remove about:blank (Viruses, Spyware and other Nasties)
- Another Trojan.Bookmarker.Gen (Viruses, Spyware and other Nasties)
Other Threads in the C# Forum
- Previous Thread: datagrid hyperlink
- Next Thread: EPSON POS - customer display
| Thread Tools | Search this Thread |
.net access algorithm alignment app array barchart bitmap box broadcast c# c#gridviewcolumn cast check checkbox client combobox communication control conversion csharp custom database datagrid datagridview dataset datatable datetime degrees development draganddrop drawing elevated encryption enum excel file focus form format forms function gdi+ hospitalmanagementsystem httpwebrequest image index input install java label list listbox localization login mandelbrot math messagebox mouseclick mysql operator path photoshop picturebox pixelinversion plotting pointer post programming radians read regex remote remoting richtextbox server sleep socket sql statistics stream string stringformatting sun table text textbox thread time timer update usercontrol validation visualstudio webbrowser whileloop windows winforms wpf xml






