How to pass a named parameter to an Visual FoxPro OLE DB Command?

泄露秘密 提交于 2019-12-24 13:41:29

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!