See and tell...................... |
| shreya verma replied to sri sri at 12-May-08 08:30 |
|
I did this and getting an error for the highlighted i.e Error 1 : The name 'strPassword' does not exist in the current context
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Security.Cryptography;
using System.Text;
public partial class SignIn : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if(!Page.IsPostBack)
BindData();
}
protected void btnLogin_Click(object sender, EventArgs e)
{
string constr = ConfigurationManager.ConnectionStrings["ConStr"].ToString();
SqlConnection con = new SqlConnection(constr);
con.Open();
SqlCommand cmd = new SqlCommand("Usp_CheckLogin", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue( "@userid", txtUserID.Text);
cmd.Parameters.AddWithValue( "@password", txtPassword.Text);
cmd.Parameters.AddWithValue( "@role", DDRole12.SelectedValue);
SqlDataReader sdr = cmd.ExecuteReader();
MD5CryptoServiceProvider md5Hasher = new MD5CryptoServiceProvider();
byte[] hashedBytes;
UTF8Encoding encoder = new UTF8Encoding();
hashedBytes = md5Hasher.ComputeHash(encoder.GetBytes(strPassword));
if (sdr.Read())
{
if (DDRole12.Text == "User")
{
Response.Redirect( "EmployeeProfile.aspx?empid=" + txtUserID.Text);
}
else
{
Response.Redirect( "EmployeeView.aspx?empid=" + txtUserID.Text);
}
}
else
{
Response.Write( "Your Login Unsuccessful");
}
sdr.Close();
con.Close();
}
private void BindData()
{
try
{
string constr = ConfigurationManager.ConnectionStrings["ConStr"].ToString();
SqlConnection con = new SqlConnection(constr);
con.Open();
DataSet ds = new DataSet();
SqlDataAdapter sda = new SqlDataAdapter("Select distinct * from Login1", con);
sda.Fill(ds);
DDRole12.DataTextField = "Role";
DDRole12.DataValueField = "Role";
DDRole12.DataSource = ds;
DDRole12.DataBind();
con.Close();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
} |
|