I have this code and need to complete it..
string conn_str =
@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\mydb.mdf;
Integrated Security=True;User Instance=True";
SqlConnection conn = new SqlConnection(conn_str);
SqlCommand cmd = new SqlCommand("SELECT Password FROM Users WHERE UserName=@un", conn);
cmd.Parameters.Add("@un", SqlDbType.NVarChar);
cmd.Parameters["@un"].Value = **???**;
conn.Open();
string pwd = (string)cmd.ExecuteScalar();
conn.Close();
I have some values in sql data: Tables: Users Username Password
Now in login page i have textboxNAME and textboxPassword and if user type right login info(that in database) it refers him to default.aspx
Try
cmd.Parameters["@un"].Value = textboxName.Text;
and
if(textboxPassword.Text.Equals(pwd))
{
Request.Redirect("default.aspx");
}
else
{
//login failed
}