473,407 Members | 2,598 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

How do I set different login paths depending on the user credentials provided.

Hi , I have a Login page and want that if the user credentials provided are those of the Administrator(Username = Administrator) then a Window Form App Page called "AdminPage" should open up. Else another Window Form App called "Main_Page" should open up.

What I have tried:

Hide Expand Copy Code
try
{
SqlConnection cn = new SqlConnection("Data Source=PV10\\LOCALSERVER;Initial Catalog=SmallSoftwareDB;Integrated Security=True;Pooling=False");
SqlCommand cmd = new SqlCommand("select * from UserCredentials where Username='" + textBox1.Text + "' and Password='" + textBox2.Text + "'", cn);
SqlDataReader dr;
cn.Open();
dr = cmd.ExecuteReader();
int cnt = 0;
while (dr.Read())
{
cnt++;
}
if (cnt == 1)
{
MessageBox.Show("Successful Login...", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
string query = "select Username, Password from UserCredentials where Username='Administrator";
SqlCommand cmdA = new SqlCommand(query, cn);
dr = cmdA.ExecuteReader();
int k = 0;
while (dr.Read())
{
k++;
}
if (k == 1)
{
AdminPage A_P = new AdminPage();
A_P.Tag = this;
A_P.Show(this);
Hide();
}
Main_Page Mp = new Main_Page();
Mp.Tag = this;
Mp.Show(this);
Hide();
cn.Close();
textBox1.Clear();
textBox2.Clear();
}
else
{
MessageBox.Show("Invalid UserName or Password", "Message", MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning);
textBox1.Clear();
textBox2.Clear();
}
}
catch (Exception err)
{
MessageBox.Show(err.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
Sep 22 '16 #1
0 1113

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: TBone | last post by:
Anyone, I have a user "john" whose machine is part of the "job" domain. He is trying to establish an odbc connection to an MS SQL 2000 server on the "school" domain. He uses Windows...
1
by: pmud | last post by:
Hi , I created a very simple ASP.NET application & am getting the following error: Login failed for user 'NT AUTHORITY\NETWORK SERVICE' Exception Details: System.Data.SqlClient.SqlException:...
2
by: Frederik | last post by:
Hi, First sorry for my english I'm french. I developped a web app that work good under XPDEVSERVER machine (iis5) and SqlServerDevelopper Edition. I get problem when I moved this app to an...
5
by: Matthew Louden | last post by:
I wrote ASP.NET application that access SQL Server database. When I run the application, it yields "Login failed for user '<COMPUTER_NAME>\ASPNET'" error message. I then did the following, but...
5
by: cdlipfert | last post by:
Our intranet is running under windows integrated security. We have domain users that want to access our intranet site via ssl vpn. SSL VPN can not authenticate against services that run under...
10
by: musosdev | last post by:
Wonder if someone can help! We're getting the following error on our Intranet system as soon as we login.. ------------------ Exception Details: System.Data.SqlClient.SqlException: Login...
1
by: Srinivas Chintakindi | last post by:
Hi All, I am developing one ASP.NET 2.0 application in which user test the remote sql server existance. User enters remote sql server name, data base name, authentication mode, user name,...
0
by: kkos | last post by:
I noticed the following issue posted as a double-hop issue in many discussion boards but found no answers that explain how to pass the second hop with windows auth from IIS ASPX page to remote SQL...
1
by: =?Utf-8?B?Qi5BaGxzdGVkdA==?= | last post by:
Hi all, This is something that I have been toying with for about a week now. What I want to achieve is Install a Service with Customised parameters (using InstallUtil.exe) for User Name. Example...
4
by: Brett | last post by:
I have an ASP.NET 2.0 application that uses Forms Authentication. The startup page contains just a login control, and the site works well on an IIS 6 web server. I am now setting the site up on...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.