title: How to get output parameter value from ExecuteNonQuery in enterprise library (c#)?
body: <p>my stored procedure is :</p>
  
  <pre><code>create Procedure spSetUser
  (
      @Name NVarchar(50),
      @OrganicTitle NVarchar(30),
      @UserName NVarchar(20),
      @Password NVarchar(16),
      @Result Int Output
  )
  As
  Begin
      Set @Result = -1    
      If Not Exists(Select UserId From dbo.Users Where UserName=@UserName)
      Begin
          Insert Into dbo.Users (Name,OrganicTitle,UserName,[Password]) 
          Values(@Name,@OrganicTitle,@UserName,@Password) 
          Set @Result = SCOPE_IDENTITY()
      End
      Return
  End
  Go
  </code></pre>
  
  <p>and my class is (in microsft enterprise library):</p>
  
  <pre><code>[DataObjectMethod(DataObjectMethodType.Insert)]
  public Int32 SetUser(UserFieldSet Data)
  {
      Int32 Result = 0;
      object[] values = new object[] { Data.Name, Data.OrganicTitle, Data.UserName, Data.Password, Data.UserId };
      Result = Db.ExecuteNonQuery("spSetUser", values);
      return Result;
  }
  </code></pre>
  
  <p>Result is roweffected of execute stored procedure, but I want get value of @Result (output parameter of procedure), How can I get it ?</p>
  
  <p>UserFieldClass is :</p>
  
  <pre><code>public class UserFieldSet
  {
      public Int32 UserId;
      public String Name;
      public String OrganicTitle;
      public String UserName;
      public String Password;
  }
  </code></pre>
  
  <p>Tip : I know must use this code for get @Result:</p>
  
  <pre><code>public Int32 SetUser(UserFieldSet Data)
  {          
      Int32 Result = 0;
      DbCommand DbCmd = Db.GetStoredProcCommand("spSetUser");
      Db.AddInParameter(DbCmd, "@Name", DbType.String, Data.Name);
      Db.AddInParameter(DbCmd, "@OrganicTitle", DbType.String, Data.OrganicTitle);
      Db.AddInParameter(DbCmd, "@UserName", DbType.String, Data.UserName);
      Db.AddInParameter(DbCmd, "@Password", DbType.String, Data.Password);
      Db.AddOutParameter(DbCmd, "@Result", DbType.Int32, Int32.MaxValue);
      Db.ExecuteNonQuery(DbCmd);
      Result = (Int32)Db.GetParameterValue(DbCmd, "@Result");
      return Result;
  }
  </code></pre>
  
  <p>But I can get it with this methd :</p>
  
  <pre><code>Result = Db.ExecuteNonQuery("spSetUser", values);
  </code></pre>