Click here to Skip to main content
15,901,284 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hello Friends,

am working on Asp.net c#, SqlServer 2005.

I have two pages in my project,

1) First page is for entering records
2) Second page is for viewing records.

In first page i have two textboxes
Department textbox and Password Textbox

when i click submit, this textboxes values will be stored in database.
Till here it is working fine.

On Second page I have dropdownlist(Department) and a password textbox.
- for dropdownlist i will retieve and display the value from Database which i have entered on my first page textbox.

So my problem is ...............

On my second page I have Dropdownlist(Department) , Textbox(Password) , and OK button

when i select department from dropdownlist and entered password, the password should match the dropdownlist selected item.

i can click OK button to view the records.

When i click OK button, the password should match the dropdownlist selected item.

or else it must display a popup message Invalid Password, Please try again

====================================================

In dropdownlist I have Departments as :

IT
logistics
Finance
Administration

I have two fields in my sqlsever 2005 db table(DeptTable)
Department and Password

for IT the password is XXIT
and for Finance the password is XXFinance
and for Administration the password is XXAdministration


Please can anybody can show me how to do this

Thanks in @dvance.
Posted
Updated 20-Apr-13 0:03am
v3
Comments
OriginalGriff 20-Apr-13 5:53am    
What part are you having a problem with?
Remember, we can't see your screen, so we only get the info you give us.
So we have no idea what your passwords are stored as, where they are stored, how you access them, or what kind of data you put in your drop down.
So as it stands, we can't help much!
Use the "Improve question" widget to edit your question and provide better information.
Software Engineer 892 20-Apr-13 6:04am    
I have improved the question,
please help
thanks

1 solution

So read the data from your DB:
C#
using (SqlConnection con = new SqlConnection(strConnect))
    {
    con.Open();
    using (SqlCommand cmd = new SqlCommand("SELECT Password FROM DeptTable WHERE Department = @DEPT", con))
        {
        cmd.Parameters.AddWithValue("@DEPT", myDropDownList.SelectedValue);
        string deptPass = cmd.ExecuteScalar() as string;
        if (deptPass == tbPassword.Text)
            {
            ... all ok
            }
        }
    }
 
Share this answer
 
Comments
MuhammadUSman1 22-Apr-13 1:41am    
+5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900