Click here to Skip to main content
15,909,437 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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
Posted

1 solution

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'
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900