[Mono-list] IDbParameter generic parameter handling

Jaroslaw Kowalski jarek@atm.com.pl
Wed, 15 Jan 2003 09:56:28 +0100

I'm looking for a generic way to implement queries with parameters for my
application. There are IDbParameter, IParameter interfaces that seem to do
the job, but there's one confusion:

Some providers (like Sql, OleDb...) on MS.NET require the parameters to be
named as @param1, @param2, @param3. Some (like Odbc on MS.NET) require
parameters to be positional and marked as '?' in query text. Here are some
remarks from MSDN documentation on "OdbcParameter.ParameterName"

Instead of named parameters, the ODBC .NET Provider uses positional
parameters that are marked with a question mark (?) in the syntax of the
command text. Parameter objects in the OdbcParameterCollection and the
actual parameters accepted by the stored procedure or parameterized SQL
statement correspond to each other based on the order in which the
OdbcParameter objects are inserted into the collection rather than by
parameter name. Parameter names can be supplied, but will be ignored during
parameter object binding.

Mono used to have some form of generic, config-driven provider that seemed
to unify different providers. What happened to it? I cannot find it in CVS
anymore. Could it be used to provide some unification to this parameter
handling problem?

For now the only thing I can do is to try both methods for specifying
parameters, and whenever one fails on execute, revert to the other one and
make it a default. Can you do it better?