简体   繁体   中英

C# Fill Data Grid View after using input list

I really need your expert help :). Expanding on what I have learnt from querying data sets using adapters and filling a Grid View. I need some help on the following task.

I have a SQL Server Database which I am querying using C#. I already have solid working solutions of by a date range, a specific value. However, the business user would like to search by a list of values they provide as input into a form.

Similar to the below: adapter.SelectCommand.Parameters.AddWithValue("@mindate", textBox1.Text);

The input will be taken from a text box or similar form based element. There should be no defined limit to the number of values eg I don't want to prevent the user from inputting 100 values for example.

By way of example. User input: doc1.num1.value;doc2.num1.value;doc3.num1.value etc Note: The document number field may contain a full stop. However, each value will be terminated by a ';'

In the above example, we would run the following query: select employee_id, docNumbers from tableName where docNumbers in (inputlist)

And the output would be: Record 1: 1, doc1.num1.value Record 2: 2, doc2.num1.value Record 3: 3, doc3.num1.value

Thanks in advance guys and gals.

我猜您正在寻找查询时正在使用IN子句。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM