all groups > sql server programming > july 2006 >
You're in the

sql server programming

group:

SQL Server 2005 throught OLEDB : Named parameter problem ?


SQL Server 2005 throught OLEDB : Named parameter problem ? Sylvain Devidal
7/21/2006 9:05:22 PM
sql server programming: Hello,

I'm designing a web application that must be able to connect different
databases.
So I decided to use OleDb connector instead of SqlClient.
While with SqlClient, I can run queries like "select * from mytable where
col = @param" then giving a value to the parameter, I get an error when
doing the same with SQL Server 2005.
I checked with Access, SQL Server 2000 and Oracle : all accept this syntax
through OleDb. SQL Server 2005 doesn't.
I have to use old school way : "select * from mytable where col = ?". But
this syntaxe is bad coz I'm not sure of the parameters order.

Why ? :(

..NET 2.0 / C# language
Windows 2003 Server Entreprise Edition SP 1 / IIS 6
SQL Server 2005 Express with advanced
Re: SQL Server 2005 throught OLEDB : Named parameter problem ? Dan Guzman
7/22/2006 10:15:38 AM
OleDb uses '?' parameter tokens rather than the '@ParameterName' tokens in
the SQL statement string. Consequently, parameters are positional (mapped
in the order parameters are added to the command parameters collection).
However, you can specify meaningful OleDbParameter names so that you easily
reference the parameters by name rather than ordinal in your application
code.

--
Hope this helps.

Dan Guzman
SQL Server MVP

[quoted text, click to view]

AddThis Social Bookmark Button