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);

}

}

}


Click here to sign in and reply. You could earn money via our $500 contest just for being helpful.
  Password Authentication - shreya verma  12-May-08 03:02 3:02:34 AM
      calrity .. - santhosh kapa  12-May-08 03:04 3:04:28 AM
          Look........ - shreya verma  12-May-08 03:17 3:17:04 AM
              check here - santhosh kapa  12-May-08 03:20 3:20:24 AM
              Encryption - sri sri  12-May-08 03:24 3:24:09 AM
                  Re: Password - Chirag Bhavsar  12-May-08 05:13 5:13:43 AM
      Details - sri sri  12-May-08 03:20 3:20:52 AM
          Tell... - shreya verma  12-May-08 03:25 3:25:50 AM
              use MD5 encryption... - Vasanthakumar D  12-May-08 04:31 4:31:52 AM
              check these.. - santhosh kapa  12-May-08 04:32 4:32:50 AM
              Try this - sri sri  12-May-08 04:40 4:40:02 AM
                  See and tell...................... - shreya verma  12-May-08 08:30 8:30:56 AM
                      you have not declared strPassword... - Vasanthakumar D  12-May-08 08:34 8:34:39 AM
                          password is not secured - shreya verma  12-May-08 08:39 8:39:36 AM
                              keep password textbox as is.. - santhosh kapa  12-May-08 09:19 9:19:45 AM
                              set TextMode = "Password" for password textboxes.. - Vasanthakumar D  13-May-08 12:12 12:12:46 AM
          Tell This!!!!!!!! - shreya verma  12-May-08 04:05 4:05:47 AM
              Refer This - sri sri  12-May-08 04:49 4:49:27 AM
View Posts