来自表单输入的C#动态SQL查询 [英] C# dynamic SQL query from Form Input

查看:136
本文介绍了来自表单输入的C#动态SQL查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有textbox1,execute按钮和datagridview1的表单,其中显示了执行的查询,还有一个表单具有listbox1的表单,其中输入文本在C#表单上显示,然后我想在datagridview1中显示查询结果搜索火山口是动态的意思,请参见以下示例

I have a form with textbox1,execute button,and datagridview1 where the query executed is displayed also the form have listbox1 where the input text is diplayed on a C# form,then I would like to display the query results in datagridview1 where the searching crateria is dynamic meaning see this examples

table1
colomn1: colomn2: colomn3
1      : a      : a1    
2      : a      : a2
3      : b      : b1
4      : b      : a2
5      : c      : a2
6      : c      : c1
7      : c      : a1
Then the user enter culumn3 fields in the form(textbox1)
then the system generate like this
1. if textbox1:a1
      datagridview1:a
                   :c
      listbox1:a1
2. if textbox1:a2
      datagridview1:a
                   :c
                   :b
      listbox1:a1
              :a2
the searching crateria is it searchs colomn2 field having colomn3 fieald which is in textbox1, for the next choise of the user it searchs having the first or the current input in textbox1 

,然后在我的表单中双击execute按钮后,代码将是什么样.
感谢您的建议"

then what would the code look like after double clicking the executebutton in my form.
"thank u for ur advice"

推荐答案

应该有两个组合框和一个文本框.组合框应具有列名.第二个应具有等于,大于等的关键字.文本应让用户提供值.

然后,应该有一个存储过程,将这三个控件中的值作为参数并创建where子句并执行它.
There should be two comboboxes and a textbox. Combobox should have column names. Second one should have the keywords like equal to, greater than etc. The text should let the user give values.

Then, there should be stored procedure that takes in the values in these three controls as parameters and create the where clause and execute it.


这篇关于来自表单输入的C#动态SQL查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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