SqlConnection con = new SqlConnection("server=.;uid=sa;pwd=;database=pubs);
string sql = "select * from table1 where name like '"+this.txtbox1.text+"'";//按名字模糊查
SqlDataAdapter da= new SqlDataAdapter(sql,con);
DataSet ds = new DataSet();
da.Fill(ds,"table1");
DataView dv= new DataView(ds.Tables["talbe1"]);
this.datagrid1.DataSource = dv;
this.datagrid1.DataBind();
貌似写在Button1按扭里就行了
SQL:
SELECT * FROM TABLE1 T WHERE T.字段名 LIKE '%"+this.txtbox1.text+"%';