title: How To Validate User Login with WindowsForm + SqlServer
body: <p>I have the store procedure for validating user id and password like this</p>
  
  <pre><code>PROCEDURE [dbo].[CheckLoginByUserIdAndPassword2]              
  
  @UserId char(15),            
  @Password char(40)        
  AS                                      
  BEGIN                                      
   -- SET NOCOUNT ON added to prevent extra result sets from                                      
   -- interfering with SELECT statements.                                      
   SET NOCOUNT ON;                
      select Name, UserPersonalId, UserId from MSUSERPERSONALINFO    
      where UserId = @UserId  and Password=@Password           
  END
  </code></pre>
  
  <p>but , any idea what kind of code that should in my c# (windowsform application) to access this store procedure and receive the return value whether the login is successful or failed one?</p>
  
  <p>I have made my code for calling that procedure , but still I cant set the return value..</p>
  
  <pre><code>try
              {
                  string sp_name = "dbo.CheckLoginByUserIdAndPassword2";
  
                  SqlConnection SqlCon = new SqlConnection("Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=jdwlrc_db;Data Source=.");
                  SqlCon.Open();
  
                  SqlCommand SqlCom = new SqlCommand(sp_name, SqlCon);
  
                  SqlCom.CommandType = CommandType.StoredProcedure;
  
                  SqlCom.Parameters.Add(new SqlParameter("@UserID",nama));
                  SqlCom.Parameters.Add(new SqlParameter("@Password",password));
  
                  SqlCom.ExecuteScalar();
                  SqlCon.Close();
  
                  return true;
              }
  
  
              catch
              {
                  return false;
              }
  </code></pre>
  
  <p>thx a lot..</p>