locked
Which method for adding OracleParameter to a command has the least performance overhead? RRS feed

  • Question

  • User1000638852 posted

    I have seen two methods of adding OracleParameters to a db request in .Net:

    1) creating an OracleParameters[] array and adding individual OracleParameters one-by-one

    OracleParameters[0] = new OracleParameter(...)

    2) creating an OracleCommand and using

    OracleCommand.Parameters.Add(new OracleParameter(...)) 

    Of these two, is one preferred in terms of performance?

    Are there any other methods?

    Has anyone got hard numbers on this?

    Tuesday, August 26, 2014 2:09 PM

All replies

  • User-1360095595 posted

    To me, method 2 is nicer. Can't really say why, but it's my preference. I dislike working with arrays and try to avoid them whenever possible.

    Now, as far as performance I doubt you'll see any measurable differences between the two, so don't sweat it :) and use the one you prefer.

    Actually my preference is to use the AddWithValue() method but that's a minor difference/preference from using .Add().

    Tuesday, August 26, 2014 3:26 PM