如何编写查询查询。

编程入门 行业动态 更新时间:2024-10-28 04:19:17
本文介绍了如何编写查询查询。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

大家好, 我有一个来自列表框,我的列表框显示客户名称和选择模式是多个。我选择3项或更多项目然后点击搜索按钮。 单项选择工作正常,显示数据正确。但我的列表框查询中的一个或多个选择不起作用。如何编写查询。? 数据库客户端名称字段是否存在。 如何使用多个客户端名称搜索数据单列。我将给出client_name =''san,jhone,dev''然后显示这些客户端名称的相关数据。 如何显示请帮助我

Hi All, I have one from with list box, my listbox shows client names and selection mode is multiple. am select the 3 or more items then click on search button. single selection is working fine and display data correct. but 1 or more selection in my list box query is not working. how to write the query.? in database client-name field is there. how to search the data single column with multiple client names.i.e am given to client_name=''san,jhone,dev'' then display the related data on these client-names. how to display please help me

推荐答案

首先准备字符串变量,其中包含listbox中用逗号(,)分隔的所有选定值,并带有以下代码 First prepare string variable which contains all selected values in listbox separated by comma(,) with following code string selecteditems = ""; for (int i = 0; i < listBox1.Items.Count; i++) { if (listBox1.GetSelected(i)) { selecteditems += "'"+listBox1.GetItemText(listBox1.Items[i])+"',"; } } selecteditems = selecteditems.Remove(selecteditems.Length - 1);

现在写你的选择查询为 从客户服务中选择* client_name in(+ selecteditems +) 这肯定会帮助你.. 很开心。 如果它帮助你忘记点击接受ans并投票支持它。 享受:)

Now write ur select query as " Select * from clienttable where client_name in ("+ selecteditems +")" this will surely help u.. hav a great time. If it helps u dnt forget to click on accept ans and vote for it. enjoy :)

或者,将你的列表框绑定设置 DataValueField 属性为 client_id 和 DataTextField 为 CLIENT_NAME 。 您可以发送Client_ID'[假设数据库中存在该列]作为逗号分隔值,在select查询中您可以写入 Alternatively, bind your listbox with setting DataValueField property as client_id and DataTextField as client_name. You can send the Client_ID''s [assuming that column is present in your database] as comma separated values and in select query you can write select client_id in (1,2,3) -- where 1,2,3 are selected client ids.

更多推荐

如何编写查询查询。

本文发布于:2023-10-27 02:40:08,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1532061.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!