On my current project, we wanted to use named parameters in our queries. Unfortunately, we are using the MySQL ODBC driver for .NET, and named parameters are not supported. Positional parameters are supported, so we created a little utility to help.
The helper function is straightforward to use. Instead of using connection.CreateCommand, you pass your statement and parameters to connection.CreateCommandWithNamedParamaters, like:
CreateCommandWithNamedParameters is as simple as
This code is in the public domain. Use it however you wish.
I’ve run into a similar problem using ODBC in a Python project, but I hadn’t thought about faking in the names. I’ll have to give your pattern a try. Thanks for the idea.
One Comment
I’ve run into a similar problem using ODBC in a Python project, but I hadn’t thought about faking in the names. I’ll have to give your pattern a try. Thanks for the idea.