title: Returning boolean value from a stored procedure using bit
body: <p>This is my code for a stored procedure that checks for Email availability.</p>
  
  <pre><code>ALTER PROCEDURE [dbo].[usp_CheckEmailMobile](@Name VARCHAR(50), @Email NVARCHAR(50), @Password NVARCHAR(50), @CountryCode INT, @Mobile VARCHAR(50), @Result BIT OUTPUT)
  AS 
  BEGIN 
  
  
  IF EXISTS (SELECT COUNT (*) FROM AUser WHERE  [Email] = @Email AND [Mobile] = @Mobile) 
  
  
  SELECT 'FALSE'; --Email &amp;/or Mobile does not exist in database
  
  ELSE
   --Insert the record &amp; register the user 
  INSERT INTO [AUser] ([Name], [Email], [Password], [CountryCode], [Mobile]) VALUES (@Name, @Email, @Password, @CountryCode, @Mobile)  
  
  
  END
  </code></pre>
  
  <p>How do I assign the result of this SP to @Result (its the output parameter)??</p>
  
  <p>here is the cs CODE: Where am I going wron in this??</p>
  
  <pre><code>      protected void btnRegister_Click(object sender, EventArgs e)
      {
  
          SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["ConnectionString"]);
          con.Open();
  
  
  
          SqlCommand Cmd = new SqlCommand("usp_CheckEmailMobile", con);
          Cmd.CommandType = CommandType.StoredProcedure;
          Cmd.CommandText = "Registration";
          Cmd.Parameters.AddWithValue("@Name", txtName.Text);
          Cmd.Parameters.AddWithValue("@Email", txtEmailAddress.Text);
          Cmd.Parameters.AddWithValue("@Password", txtPassword.Text);
          Cmd.Parameters.AddWithValue("@CountryCode", ddlCountryCode.Text);
          Cmd.Parameters.AddWithValue("@Mobile", txtMobileNumber.Text);
          //Cmd.Parameters.Add("@Result", DbType.Boolean);
          SqlParameter sqlParam = new SqlParameter("@Result", DbType.Boolean);
          //sqlParam.ParameterName = "@Result";
          //sqlParam.DbType = DbType.Boolean;
          sqlParam.Direction = ParameterDirection.Output;
          Cmd.Parameters.Add(sqlParam);
          Cmd.ExecuteNonQuery();
          con.Close();
          Response.Write(Cmd.Parameters["@Result"].Value);
  
      }
  </code></pre>
  
  <p>went through this, dint help...
  <a href="https://stackoverflow.com/questions/3433694/how-to-run-the-stored-procedure-that-has-output-parameter-from-c">How to run the stored procedure that has OUTPUT parameter from C#?</a> </p>