tableadapter查询 [英] tableadapter query

查看:209
本文介绍了tableadapter查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



当我在sql中执行此代码时,它给了我2条记录
SELECT cod_area_ciudad,queue
FROM dbo.areas
WHERE cod_area_ciudad IN( 'mexav08aa','bogav08aa')

我在tableadapter的查询构建器中有这个。
选择cod_area_ciudad,队列
从FROM dbo.areas
在哪里cod_area_ciudad IN(@oficinas)

当我点击执行查询时,我将值mexav08aa,bogav08aa放在查询参数的值字段中,但我没有记录。

如何使用IN命令对搜索2个或更多办公室进行sql查询?

谢谢。

解决方案

你不能将多个值作为IN子句中的参数传递。你需要用另一种方法来做到这一点。我很久以前就为SQL Server 2000编写了样本,但类似的方法适用于SQL Server 2005或更新版本,允许使用XML。以下是示例

http://support.microsoft.com/kb/555266

Hi

When I execute this code in sql, it gives to me 2 records
SELECT     cod_area_ciudad, queue
FROM         dbo.areas
WHERE    cod_area_ciudad IN ('mexav08aa','bogav08aa')

I have this in the query builder of a tableadapter

SELECT     cod_area_ciudad, queue
FROM         dbo.areas
WHERE     cod_area_ciudad IN (@oficinas)

when i do click in execute query, I put the value mexav08aa,bogav08aa in the value field of query parameters but I get no records.

How do I to use a sql query with the IN command for search 2 or more offices???

Thanks.

解决方案

You cannot pass multiple values as a parameter in IN clause. You would need to use another way to do this. I have wrote sample long time ago for the SQL Server 2000, but similar approach works for SQL Server 2005 or newer, which allow to use XML. Here is the sample

http://support.microsoft.com/kb/555266


这篇关于tableadapter查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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