private void Update_Load(object sender, EventArgs e) { DataSet ds = SqlDesigner.ExecuteDataSet("select * from Ls_Mms_Info"); DataTable dt = ds.Tables[0]; dataGridView1.DataSource = dt; }
//查询 private void button3_Click(object sender, EventArgs e) { string sql = "select * from Ls_Mms_Info where 1 = 1"; if (textBox1.Text.Trim() != "") { sql = sql + " and info = '" + textBox1.Text + "' "; } if (textBox2.Text.Trim() != "") { sql = sql + " and more = '" + textBox2.Text + "' "; } if (textBox3.Text.Trim() != "") { sql = sql + " and name = '" + textBox3.Text + "' "; } DataSet ds = SqlDesigner.ExecuteDataSet(sql); DataTable dt = ds.Tables[0]; dataGridView1.DataSource = dt; }