Search code examples
c#.netado.netsqlcommandsqlparameter

SqlParameter ParameterDirection


A developer asked me today if there are disadvantages or risks while setting all SqlParameters for a SqlCommand to ParameterDirection.InputOutput. I coudn't think of any expect maybe some performance issues (but not even sure of that)? Someone having experience with that?


Solution

  • There is no risk if the code doesn't attempt to use the values afterwards. However, if code is using the values again then the value may have changed inside the stored procedure. Performance wise, the values are marshalled back from SQL if they are output parameters.

    There is no point in doing this really. Not all DBMS support output parameters so you would be increasing coupling for zero gain.