查询
SqlConnection con = new SqlConnection(ConnStr);
string str = "select * from tb_user";
adp = new SqlDataAdapter(str, con);
DataSet ds = new DataSet();
adp.Fill(ds, "tb_user");
SqlCommandBuilder MyCb = new SqlCommandBuilder(adp);
MyTab = ds.Tables["tb_user"];
MyTab.PrimaryKey = new DataColumn[] { MyTab.Columns["uacc"] };
DataGridView.MultiSelect = false;
if (this.checktxt.Text != string.Empty)
{
bindingSource1.DataSource = MyTab;
bindingNavigator1.BindingSource = bindingSource1;
DataGridView.DataSource = bindingSource1;
DataView dv = ds.Tables["tb_user"].DefaultView;
dv.RowFilter = "uacc like '%" + checktxt.Text.Trim() + "%'";
}
[
本帖最后由 tanlang1218 于 2014-8-5 18:37 编辑 ]