oledb parameters: why does their order matter?

  • Thread starter Thread starter Timo
  • Start date Start date
T

Timo

I would be grateful if someone could explain why oledb parameters must
be added to the Parameters collection in the order matching the order of
the counterpart columns in the CommandText sql statement -- even when
the source column name is provided?

TIA
Timo
 
¤ I would be grateful if someone could explain why oledb parameters must
¤ be added to the Parameters collection in the order matching the order of
¤ the counterpart columns in the CommandText sql statement -- even when
¤ the source column name is provided?

Because named parameters are not supported by the .NET OLEDB provider even though you can specify
them. .NET OLEDB simply ignores them and relies on the ordinal position of the parameters in the
Parameters collection.


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
Thanks, Paul. I should have phrased my question differently. Why does
..NET OLEDB ignore named parameters? What is the reasoning behind this
design when the command-type is Text, and the SQL statement is available
to be parsed?
Thanks
Timo
 
The .NET OleDb provider does not support named parameters--even if the
backend does. SQL Server supports named parameters, but the OLE DB provider
does not. The SqlClient native (managed) .NET data provider does support
named parameters. Because of this the order DOES matter and you must include
all parameters (and mark them with "?" or the provider-specific marking
symbol) when using OLE DB.

hth

--
____________________________________
Bill Vaughn
MVP, hRD
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
¤ Thanks, Paul. I should have phrased my question differently. Why does
¤ .NET OLEDB ignore named parameters? What is the reasoning behind this
¤ design when the command-type is Text, and the SQL statement is available
¤ to be parsed?

Currently it is by design. I cannot tell you at this point whether support for named parameters will
be added to the native .NET OLEDB provider.


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
Back
Top