title: compare the password user input against from database
body: <p>i'm new to asp.net, i'm writing a login page for learning asp.net, here is the error with the script. When i enter the password only contains english letters, there are no errors, but when i enter the password contain digit/only digit for example, abc123 or 123, line 28 will produce an error, anyone knows what the problems?</p>
  
  <p>thanks</p>
  
  <pre><code>Object reference not set to an instance of an object.
  
  Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
  
  Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
  
  Source Error: 
  
  
  Line 26:             string cmdStr2 = "Select Password from [user] where UserName = '" + TextBox2.Text + "'";
  Line 27:             SqlCommand pass = new SqlCommand(cmdStr2, con);
  Line 28:             string password = pass.ExecuteScalar().ToString();
  Line 29:             
  Line 30:             Label1.Text = password;
  
  Source File: c:\inetpub\web1\Login.aspx.cs    Line: 28 
  
  Stack Trace: 
  
  
  [NullReferenceException: Object reference not set to an instance of an object.]
     Login.Button1_Click(Object sender, EventArgs e) in c:\inetpub\web1\Login.aspx.cs:28
     System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118
     System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +112
     System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
     System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
     System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
     System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563
  </code></pre>