c#windows应用程序中的搜索工具 [英] Search Tool in c# windows application

查看:67
本文介绍了c#windows应用程序中的搜索工具的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的团队,



我有如下所述的要求,如果你们能帮助我实现这一点请求。



我想创建一个对话框表单,搜索任何数据库(通过传递表名)表和同一个表中的任何字段,并将所选值传递给调用表单。



Schenerio就像我们必须从数据库中搜索员工,并选择网格员工代码中的任何行,以父表格的员工代码填充更新,类似的如果我必须使用dearch departments表,那么我可以使用相同的搜索者另一种形式的这个部门表的工具。



其他方式SAP像搜索窗口,同一窗口适用于所有表格。



Vijay

Dear Team,

I have a requirement as stated below, Request if you guys can help me achive this.

I want to make a dialog form which searches any database (by passing table name) table and any field in same table and pass the selected value to calling form.

Schenerio is like we have to search employees from database and on selection of any row in grid employee code gets populated in employee code in parent form for update, similarly if i have to dearch departments table then i can use same searcher tool for this departments tables in another form.

In Other way SAP like search window, same window works for all forms.

Vijay

推荐答案

如何在表单上使用2列网格?



在第一列中,每行包含允许查询参数的字段(名称) - 这可以通过读取t来填充他表的元数据。在第二列中,您接受来自用户的每个字段的参数。



当用户单击搜索时,您遍历网格,并从任何第1列字段名称及其第2列查询值/参数构建一个选择查询,其中第2列值为非空



你能得到我说的吗?



例如(你必须在下面''网格'中''|''排成一行''



部门

=====================

Dept_Name |

Dept_Manager | Fred

Dept_Code | 001

Dept_Type |



建立一个查询''select * from部门Dept_Manager =''Fred''和Dept_Code =001;''



你可以为第一列硬编码''好名字''如果列/字段名称不漂亮



我见过各种复杂的查询用于避免此类事情建立像这样的SQL查询字符串(sql注入式攻击),ymmv



''g''
how about using a 2 column grid on a form ?

In the first column, each row contains the field (name) on which you will allow a query parameter for - this can be populated by reading the meta-data for the table. In the second column, you accept the parameters for each field from the user.

When the users click''s ''search'', you traverse the grid, and build a select query from any column 1 field name and its column 2 query value/parameter where the column 2 value is non null

do you get what Im saying ?

eg (you have to imaging the ''|'' line up in the below ''grid''

Departments
=====================
Dept_Name |
Dept_Manager | Fred
Dept_Code | 001
Dept_Type |

builds a query ''select * from departments where Dept_Manager = ''Fred'' and Dept_Code = "001";''

You could hard code ''nice names'' for the first column if the Column/Field names arent pretty

Ive seen all sorts of complex queries used for this sort of thing to avoid building a sql query string like this (sql injection type attacks), ymmv

''g''


这篇关于c#windows应用程序中的搜索工具的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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