问题
I recently accessed some DBF in VS.NET, using Visual FoxPro OLE DB Provider. Everything worked fine until I found that I could not figure out how to pass a parameter to the query. I used this as query
Select `group`, `i_name`, `j_name`, ... From `mytable` Where `valid` AND `group` IN (@`group1`, @`group2`);
And added two parameters named group1
and group2
, with string values, to the parameter collection (ie. IDbCommand.Parameters
).
Then I received an OleDbException, telling me Syntax error.
I've tried this
Select `group`, `i_name`, `j_name`, ... From `mytable` Where `valid` AND `group` IN (?, ?);
And it worked.
I just wonder if the FoxPro OLE DB Provider supports the named parameters? If so, how to reference it in the query?
回答1:
The FoxPro OLE DB Provider does not support named parameters. I found this to be a problem for some stuff that I worked on so I ended up created a wrapper around the FoxPro OLE DB Provider. Here is an example using named parameters with my provider if you are interested.
来源:https://stackoverflow.com/questions/29602133/how-to-pass-a-named-parameter-to-an-visual-foxpro-ole-db-command