2

What is the benefit of using parameter placeholder:

VALUES (?, ?, ?, ?, ?, ?)

instead of:

VALUES ('@uNameParam', '@bNavnParam', '@passwdParam', '@pc_idParam', '@noterParam', '@licens_idParam')
2
  • 1
    No "benefit" - some database providers just simply don't support the named parameters (@uNameParam) like SQL Server does...... Commented Aug 10, 2014 at 12:23
  • Named parameters should not be in quotes - See: stackoverflow.com/questions/751172/… Commented Oct 3, 2016 at 10:55

2 Answers 2

3

The first is an example of unnamed parameters. When supplying values for those parameters, the order in which you specify values matters, so that it can match parameters with parameter values correctly.

The second is an example of named parameters. You can usually provide values in any order you want, though that's not always the case.

I don't think there's any benefit of one over the other... it just depends on what's supported for your database and the driver you're using. If you can use either, I'd go for the named parameters for readability alone.

Sign up to request clarification or add additional context in comments.

Comments

1

Named parameters allows the developer from being free in the order parameters are added to the parameter collection. The ? approach, in my opinion, is dangerous coding.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.