gsharp
gsharp

Reputation: 27937

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?

Upvotes: 1

Views: 1245

Answers (2)

Adam Straughan
Adam Straughan

Reputation: 2848

As a developer you should be clearly showing your intent.

If the parameter is not in/out then setting the direction to in/out will only add confusion not value.

Upvotes: 2

Adam Houldsworth
Adam Houldsworth

Reputation: 64517

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.

Upvotes: 2

Related Questions