title: In C# how to get return value from stored procedure using ExecuteNonQuery
body: <p>I have the following query:</p>
  
  <pre><code>create proc [dbo].[DeleteParts] 
      @TransNo nvarchar (6), @fpart nvarchar(25) 
  AS 
      DECLARE @Returns BIT 
      SET @Returns = 1 
  
      BEGIN 
         TRY  
            BEGIN TRANSACTION 
  
            DELETE FROM PARTABLE 
            WHERE TransNo = @TransNo and fpart = @fpart
  
            COMMIT 
         END TRY 
         BEGIN CATCH   
             Print 'Delete failed'    
             SET @Returns = 0      
             -- Any Error Occurred during Transaction. Rollback     
             IF @@TRANCOUNT &gt; 0       
                 ROLLBACK  -- Roll back 
         END CATCH
  
         RETURN @Returns
  </code></pre>
  
  <p>This compiles perfectly fine.</p>
  
  <p>In C#, I want to execute this query and get the return value.</p>
  
  <p>My code is as below:</p>
  
  <pre><code>using(System.Data.SqlClient.SqlCommand deletecommand = this._connection.CreateCommand())
  {
     deletecommand.CommandText = "DeleteParts";
     deletecommand.CommandType = System.Data.CommandType.StoredProcedure;
     deletecommand.Parameters.AddWithValue("@TransNo", ItemSODBOM.SONO);
     deletecommand.Parameters.AddWithValue("@fpart", ItemSODBOM.fbompart);
  
     string ReturnValue = deletecommand.ExecuteNonQuery().ToString();
  }
  </code></pre>
  
  <p>It does not give me any error but instead it is returning number of rows affected, I want to return 1 or 0. </p>
  
  <p>Example: if delete operation success then return 1 and if it fails then return 0.</p>
  
  <p>Any help with source code would be appreciated. </p>
  
  <p>Thanks,</p>
  
  <p>Pradeep</p>