using System; using System.Collections.Generic; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data.SqlClient; using System.Configuration; public partial class home : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["RegconnectionString"].ConnectionString); con.Open(); string cmdStr = "Select Count(*) from Registration where UserName='" + TextBox1.Text + "'"; SqlCommand Checkuser = new SqlCommand(cmdStr, con); int temp = Convert.ToInt32(Checkuser.ExecuteScalar().ToString()); if (temp == 1) { string cmdstr2 = "Select Password from Registration where UserName='" + TextBox1 + "'"; SqlCommand pass = new SqlCommand(cmdstr2, con); string password = pass.ExecuteScalar().ToString(); con.Close(); if (password == TextBox2.Text) { Session["New"] = TextBox1.Text; Response.Redirect("gallery.aspx"); } else { Label1.Visible = true; Label1.Text = "Invalid Password...!!!"; } } else { Label1.Visible = true; Label1.Text = "Invalid UserName...!!!"; } } }
object password = pass.ExecuteScalar(); if (password != null) { //here you can use password }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)