如何向 C# 表适配器添加非特定于列的参数?
我第一次使用 TableAdapter 并向其添加自定义查询,并且我在向查询中添加一些搜索参数时遇到了困难,这就是我得到的:
SELECT *
FROM Orders
WHERE (id_order = @id_order) OR
(IsFor LIKE '%@word1%') OR
(IsFor LIKE '%@word2%') OR
(IsFrom LIKE '%@word1%') OR
(IsFrom LIKE '%@word2%')
当我测试执行查询时,我提示输入 id_order,但不提示输入 word1 或 word2。 我还尝试将这些直接作为参数添加到适配器中并将它们传递进去,但它们不起作用。 奇怪的是, id_order 继续工作,但其他值不会生成任何匹配项。
我的目标是允许用户输入名字和/或姓氏,并使其与具有该名字和/或姓氏的任何订单相匹配。
关于我做错了什么有什么想法吗?
I'm using a TableAdapter for the first time and adding a custom query to it, and I'm getting stuck on adding some search parameters to my query, here's what I've got:
SELECT *
FROM Orders
WHERE (id_order = @id_order) OR
(IsFor LIKE '%@word1%') OR
(IsFor LIKE '%@word2%') OR
(IsFrom LIKE '%@word1%') OR
(IsFrom LIKE '%@word2%')
When I test execute the query, I'm prompted for id_order, but not word1 or word2. I also tried adding these directly as parameters to the adapter and pass them in but they don't work. Strangely, id_order continues to work, but the other values don't generate any matches.
My goal is to allow the user to type in first &/or last name and have it match any orders with that first &/or last name.
Any ideas as to what I'm doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不需要引号或百分号。
You don't need quotes or percent signs.