使用比较运算符号进行比较查询
2014-10-15 12:14
441 查看
1.Form1.cs设计
代码如下:
代码如下:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Data.SqlClient; namespace 比较查询 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { // TODO: 这行代码将数据加载到表“studentDataSet.student”中。您可以根据需要移动或删除它。 this.studentTableAdapter.Fill(this.studentDataSet.student); //ComboBox comboBox1 = new ComboBox(); comboBox1.Items.Add("大于260"); comboBox1.Items.Add("大于270"); comboBox1.Items.Add("大于280"); comboBox1.Items.Add("大于290"); } private void button1_Click(object sender, EventArgs e) { string str = string.Empty; switch (comboBox1.SelectedItem.ToString()) { case "大于260": str = ">260"; break; case "大于270": str = ">270"; break; case "大于280": str = ">280"; break; case "大于290": str = ">290"; break; } SqlConnection con = new SqlConnection("server=localhost\\SQL2005;uid=sa;pwd=1111qq;database=student"); SqlDataAdapter dap = new SqlDataAdapter("select *from student where stuScore"+str,con); DataSet ds = new DataSet(); dap.Fill(ds,"score"); dataGridView1.DataSource = ds.Tables["score"].DefaultView; //dataGridView1.DataBind(); } } }
相关文章推荐
- 使用spring的JdbcTemplate进行查询的三种回调方式的比较
- 对于access,在数据库当中建立模糊查询时,这时用到的通配符号是“*”,而如果在VB中使用查询语句进行模糊查询时,这时就要用“%”
- Mysql中使用like进行模糊查询反斜线等符号转义处理
- 使用spring的JdbcTemplate进行查询的三种回调方式的比较
- OJ题目-使用+-|等符号表示数字,进行运算【C语言】
- Access使用查询--1.2.用选择查询进行分组数据的计算
- Oracle使用SQL语句进行递归查询
- 使用asp.net进行多关键字查询的例子
- 使用谓词进行查询
- 使用 PreparedStatement 进行模糊查询
- 在SQL中使用convert函数进行日期的查询
- 在SQL中使用convert函数进行日期的查询
- 使用用户自定义函数进行自定义查询
- 在SQL中使用convert函数进行日期的查询的代码
- 使用 PreparedStatement 进行模糊查询
- 使用反射查询类的方法和字段以及使用IS运算符号类转换和AS运算符
- 使用 WebSphere Studio Application Developer 开发 Java 程序: 与 VisualAge for Java 进行比较
- 使用多个表进行查询
- 使用JNDI进行高级DNS查询
- hibernate学习笔记(三)----------使用Query进行查询