如何将命名参数传递给 Visual FoxPro OLE DB 命令? [英] How to pass a named parameter to an Visual FoxPro OLE DB Command?

查看:72
本文介绍了如何将命名参数传递给 Visual FoxPro OLE DB 命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近使用 Visual FoxPro OLE DB Provider 在 VS.NET 中访问了一些 DBF.一切正常,直到我发现我无法弄清楚如何将参数传递给查询.我用这个作为查询

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`);

并向参数集合(即IDbCommand.Parameters)添加了两个名为group1group2 的参数,带有字符串值.

And added two parameters named group1 and group2, with string values, to the parameter collection (ie. IDbCommand.Parameters).

然后我收到一个 OleDbException,告诉我语法错误.

Then I received an OleDbException, telling me Syntax error.

我已经试过了

Select `group`, `i_name`, `j_name`, ... From `mytable` Where `valid` AND `group` IN (?, ?);

它奏效了.

我只是想知道 FoxPro OLE DB Provider 是否支持命名参数?如果是这样,如何在查询中引用它?

I just wonder if the FoxPro OLE DB Provider supports the named parameters? If so, how to reference it in the query?

推荐答案

FoxPro OLE DB 提供程序不支持命名参数.我发现这对于我从事的某些工作来说是一个问题,因此我最终围绕 FoxPro OLE DB 提供程序创建了一个包装器.这是一个 示例 如果您有兴趣,可以在我的提供程序中使用命名参数.

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.

这篇关于如何将命名参数传递给 Visual FoxPro OLE DB 命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆