Click here to Skip to main content
15,903,175 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
con.Open();
        SqlCommand cmd = new SqlCommand("select * from UserInformation where UserName =@username and Password=@password", con);
        cmd.Parameters.AddWithValue("@username",txtUserName.Text);
        cmd.Parameters.AddWithValue("@password",txtPWD.Text);
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        DataTable dt = new DataTable();
        da.Fill(dt);
        if (dt.Rows.Count > 0)
        {
            Response.Redirect("Details.aspx");
        }
        else
        {
            ClientScript.RegisterStartupScript(Page.GetType(), "validation", "<script language='javascript'>alert('Invalid Username and Password')</script>");
        }
    }
Posted
Updated 18-Jul-14 0:53am
v2
Comments
CPallini 18-Jul-14 6:54am    
Probably you have just mistyped it.
Member 10918596 18-Jul-14 7:16am    
give example
CPallini 18-Jul-14 7:53am    
Suppose the actual name of you text box is 'TextPWD'. Then 'txtPWD' is not recognized.
krishnaMurali 18-Jul-14 7:13am    
I support CPallini

1 solution

maybe its just typographical error. Check the ID of your textbox if its really txtPWD.
 
Share this answer
 

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